Adding firsts ftp class phpunit tests ( testing the addftp function )

This commit is contained in:
Squidly 2014-08-01 18:10:39 +02:00
parent 6a8e3c0df3
commit dc390c1167
1 changed files with 104 additions and 43 deletions

View File

@ -2,7 +2,7 @@
/**
* 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
@ -19,6 +19,21 @@ class m_ftpTest extends PHPUnit_Framework_TestCase
$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.
* This method is called after a test is executed.
@ -165,16 +180,62 @@ class m_ftpTest extends PHPUnit_Framework_TestCase
/**
* @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.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
global $db,$mysql,$cuid,$mem,$admin ;
// we go super-admin
$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
* @todo Implement testIs_ftp().