Adding firsts ftp class phpunit tests ( testing the addftp function )
This commit is contained in:
		
							parent
							
								
									6a8e3c0df3
								
							
						
					
					
						commit
						dc390c1167
					
				|  | @ -2,7 +2,7 @@ | ||||||
| /** | /** | ||||||
|  * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58. |  * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:58. | ||||||
|  */ |  */ | ||||||
| class m_ftpTest extends PHPUnit_Framework_TestCase | class m_ftpTest extends AlterncTest | ||||||
| { | { | ||||||
|     /** |     /** | ||||||
|      * @var m_ftp |      * @var m_ftp | ||||||
|  | @ -19,6 +19,21 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|         $this->object = new m_ftp; |         $this->object = new m_ftp; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * @return PHPUnit_Extensions_Database_DataSet_IDataSet | ||||||
|  |      */ | ||||||
|  |     public function getDataSet() | ||||||
|  |     {  $t=array("1" => "ftp/ftp.yml", | ||||||
|  |             "2" => "membres.yml", | ||||||
|  |             "3" => "domaines.yml", | ||||||
|  |             "3" => "policy.yml", | ||||||
|  |             "4" => "default-quota.yml", | ||||||
|  |             "5" => "db_servers.yml" | ||||||
|  |             ); | ||||||
|  | 
 | ||||||
|  |     return parent::loadDataSet($t); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * Tears down the fixture, for example, closes a network connection. |      * Tears down the fixture, for example, closes a network connection. | ||||||
|      * This method is called after a test is executed. |      * This method is called after a test is executed. | ||||||
|  | @ -36,8 +51,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -48,8 +63,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -60,8 +75,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -72,8 +87,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -84,8 +99,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -96,8 +111,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -108,8 +123,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -118,13 +133,13 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|      */ |      */ | ||||||
|     public function testCheck_login() |     public function testCheck_login() | ||||||
|     { |     { | ||||||
|       // Allowed
 |         // Allowed
 | ||||||
|       $this->assertTrue($this->object->check_login('plop'));  |         $this->assertTrue($this->object->check_login('plop'));  | ||||||
|       $this->assertTrue($this->object->check_login('00'));  |         $this->assertTrue($this->object->check_login('00'));  | ||||||
| 
 | 
 | ||||||
|       // Forbidden
 |         // Forbidden
 | ||||||
|       $this->assertFalse($this->object->check_login('_plop'));  |         $this->assertFalse($this->object->check_login('_plop'));  | ||||||
|       $this->assertFalse($this->object->check_login('arf+'));  |         $this->assertFalse($this->object->check_login('arf+'));  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -135,8 +150,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -147,8 +162,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -159,22 +174,68 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers m_ftp::add_ftp |      * @covers m_ftp::add_ftp | ||||||
|      * @todo   Implement testAdd_ftp(). |  | ||||||
|      */ |      */ | ||||||
|     public function testAdd_ftp() |     public function testAdd_ftp_prefix_ok() | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         global $db,$mysql,$cuid,$mem,$admin ; | ||||||
|         $this->markTestIncomplete( |         // we go super-admin
 | ||||||
|           'This test has not been implemented yet.' |         $admin->enabled=1; | ||||||
|         ); |         $mem->su("2001"); | ||||||
|  |         $queryTable               = $this->getConnection()->createQueryTable('domain', 'SELECT * FROM db_servers'); | ||||||
|  |         $row_count = $queryTable->getRowCount(); | ||||||
|  | 
 | ||||||
|  |         #first ftp account 
 | ||||||
|  |         $result=$this->object->add_ftp("phpunit","","123456","/"); | ||||||
|  |         $this->assertTrue($result); | ||||||
|  |          | ||||||
|  |         #first ftp account again ( should fail )
 | ||||||
|  |         $result=$this->object->add_ftp("phpunit","","123456","/"); | ||||||
|  |         $this->assertFalse($result); | ||||||
|  |          | ||||||
|  |         #ftp account with suffix
 | ||||||
|  |         $result=$this->object->add_ftp("phpunit","new","123456","/"); | ||||||
|  |         $this->assertTrue($result); | ||||||
|  |          | ||||||
|  |         #ftp account with suffix again should fail
 | ||||||
|  |         $result=$this->object->add_ftp("phpunit","new","123456","/"); | ||||||
|  |         $this->assertFalse($result); | ||||||
|  | 
 | ||||||
|  |         #ftp account with domain prefix ok 
 | ||||||
|  |         $result=$this->object->add_ftp("domain1.tld","","123456","/"); | ||||||
|  |         $this->assertFalse($result); | ||||||
|  | 
 | ||||||
|  |         #ftp account with domain prefix again : should fail 
 | ||||||
|  |         $result=$this->object->add_ftp("domain1.tld","","123456","/"); | ||||||
|  |         $this->assertFalse($result); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  |     /** | ||||||
|  |      * @covers m_ftp::add_ftp | ||||||
|  |      */ | ||||||
|  |     public function testAdd_ftp_prefix_not_ok() | ||||||
|  |     { | ||||||
|  |         global $db,$mysql,$cuid,$mem,$admin ; | ||||||
|  |         // we go super-admin
 | ||||||
|  |         $admin->enabled=1; | ||||||
|  |         $mem->su("2001"); | ||||||
|  | 
 | ||||||
|  |         #test with a prefix that is not the user's login
 | ||||||
|  |         $result=$this->object->add_ftp("phpunity","","123456","/"); | ||||||
|  |         $this->assertFalse($result); | ||||||
|  | 
 | ||||||
|  |         #test with a prefix that is not a domain associated to the specified user
 | ||||||
|  |         $result=$this->object->add_ftp("admin.ltd","","123456","/"); | ||||||
|  |         $this->assertFalse($result); | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * @covers m_ftp::is_ftp |      * @covers m_ftp::is_ftp | ||||||
|      * @todo   Implement testIs_ftp(). |      * @todo   Implement testIs_ftp(). | ||||||
|  | @ -183,8 +244,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -195,8 +256,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -207,8 +268,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -219,8 +280,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | @ -231,8 +292,8 @@ class m_ftpTest extends PHPUnit_Framework_TestCase | ||||||
|     { |     { | ||||||
|         // Remove the following lines when you implement this test.
 |         // Remove the following lines when you implement this test.
 | ||||||
|         $this->markTestIncomplete( |         $this->markTestIncomplete( | ||||||
|           'This test has not been implemented yet.' |                 'This test has not been implemented yet.' | ||||||
|         ); |                 ); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Squidly
						Squidly