[enh] m_variablesTest is ready

This commit is contained in:
alban 2014-03-22 15:42:59 +01:00
parent f0ad82c5d5
commit 0356fa622c
2 changed files with 83 additions and 208 deletions

View File

@ -2,12 +2,20 @@
/** /**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:59. * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:59.
*/ */
class m_variablesTest extends PHPUnit_Framework_TestCase class m_variablesTest extends AlterncTest
{ {
/** /**
* @var m_variables * @var m_variables
*/ */
protected $object; protected $object;
/**
* @return PHPUnit_Extensions_Database_DataSet_IDataSet
*/
public function getDataSet()
{
return parent::loadDataSet("variables.yml");
}
/** /**
* Sets up the fixture, for example, opens a network connection. * Sets up the fixture, for example, opens a network connection.
@ -15,6 +23,7 @@ class m_variablesTest extends PHPUnit_Framework_TestCase
*/ */
protected function setUp() protected function setUp()
{ {
parent::setUp();
$this->object = new m_variables; $this->object = new m_variables;
} }
@ -24,102 +33,126 @@ class m_variablesTest extends PHPUnit_Framework_TestCase
*/ */
protected function tearDown() protected function tearDown()
{ {
parent::tearDown();
} }
/** /**
* @covers m_variables::variable_init * @covers m_variables::variable_init
* @todo Implement testVariable_init(). * @depends testGet_impersonated
*/ */
public function testVariable_init() public function testVariable_init($variables)
{ {
// Remove the following lines when you implement this test. $this->object->variable_init();
$this->markTestIncomplete( global $conf;
'This test has not been implemented yet.' $this->assertTrue(is_array($conf));
);
} }
/** /**
* @covers m_variables::get_impersonated * @covers m_variables::get_impersonated
* @todo Implement testGet_impersonated().
*/ */
public function testGet_impersonated() public function testGet_impersonated()
{ {
// Remove the following lines when you implement this test. $variables = $this->object->get_impersonated();
$this->markTestIncomplete( return $variables;
'This test has not been implemented yet.'
);
} }
/** /**
* @covers m_variables::variable_init_maybe * @covers m_variables::variable_init_maybe
* @todo Implement testVariable_init_maybe().
*/ */
public function testVariable_init_maybe() public function testVariable_init_maybe()
{ {
// Remove the following lines when you implement this test. $this->object->variable_init_maybe();
$this->markTestIncomplete( global $conf;
'This test has not been implemented yet.' $this->assertTrue(is_array($conf));
);
} }
/** /**
* @covers m_variables::variable_get * @covers m_variables::variable_get
* @todo Implement testVariable_get().
*/ */
public function testVariable_get() public function testVariable_get()
{ {
// Remove the following lines when you implement this test. $result = $this->object->variable_get("phpunit");
$this->markTestIncomplete( $this->assertStringMatchesFormat("phpunit",$result);
'This test has not been implemented yet.'
);
} }
/** /**
* @covers m_variables::variable_update_or_create * @covers m_variables::variable_update_or_create
* @todo Implement testVariable_update_or_create(). * @expectedException \Exception
*/ */
public function testVariable_update_or_create() public function testVariable_create_exception()
{ {
// Remove the following lines when you implement this test. // Insert key with already existing key : success
$this->markTestIncomplete( $result = $this->object->variable_update_or_create("phpunit","phpunit-fail","DEFAULT",0);
'This test has not been implemented yet.' }
);
/**
* @covers m_variables::variable_update_or_create
*/
public function testVariable_create()
{
// Insert key with new key : success
$result = $this->object->variable_update_or_create("phpunit-success","phpunit","DEFAULT",0);
$this->assertTrue($result);
$this->assertEquals(2, $this->getConnection()->getRowCount('variable'));
}
/**
* @covers m_variables::variable_update_or_create
*/
public function testVariable_update()
{
$result = $this->object->variable_update_or_create("phpunit","phpunit-updated","DEFAULT",0,999);
$this->assertTrue($result);
$this->assertEquals(1, $this->getConnection()->getRowCount('variable'));
$expectedTable = $this->loadDataSet("variables-updated.yml")->getTable("variable");
$currentTable = $this->getConnection()->createQueryTable('variable', 'SELECT * FROM variable');
$this->assertTablesEqual($expectedTable, $currentTable);
} }
/** /**
* @covers m_variables::del * @covers m_variables::del
* @todo Implement testDel().
*/ */
public function testDel() public function testDel()
{ {
// Remove the following lines when you implement this test. $result = $this->object->del(999);
$this->markTestIncomplete( $this->assertTrue($result);
'This test has not been implemented yet.' $this->assertEquals(0, $this->getConnection()->getRowCount('variable'));
);
} }
/** /**
* @covers m_variables::display_valueraw_html * @covers m_variables::display_valueraw_html
* @todo Implement testDisplay_valueraw_html().
*/ */
public function testDisplay_valueraw_html() public function testDisplay_valueraw_html()
{ {
// Remove the following lines when you implement this test. // Empty string
$this->markTestIncomplete( $empty_result = $this->object->display_valueraw_html(null, "phpunit",FALSE);
'This test has not been implemented yet.' $this->assertStringMatchesFormat("<em>"._("Empty")."</em>",$empty_result);
); // Empty array
$empty_array_result = $this->object->display_valueraw_html(array(), "phpunit",FALSE);
$this->assertStringMatchesFormat("<em>"._("Empty array")."</em>",$empty_array_result);
// String
$value_result = $this->object->display_valueraw_html("value", "phpunit",FALSE);
$this->assertStringMatchesFormat($value_result,$value_result);
// String
$array_result = $this->object->display_valueraw_html(array("value","value"), "phpunit",FALSE);
$this->assertStringMatchesFormat("<ul>%s</ul>",$array_result);
} }
/** /**
* @covers m_variables::display_value_html * @covers m_variables::display_value_html
* @todo Implement testDisplay_value_html(). * @depends testVariables_list
*/ */
public function testDisplay_value_html() public function testDisplay_value_html( $variables )
{ {
// Remove the following lines when you implement this test. $valid_result = $this->object->display_value_html($variables, "DEFAULT", 0, "phpunit",FALSE);
$this->markTestIncomplete( $this->assertStringMatchesFormat("phpunit",$valid_result);
'This test has not been implemented yet.'
); $invalid_result = $this->object->display_value_html($variables, "DEFAULT", 0, "phpunit-absent",FALSE);
$this->assertStringMatchesFormat("<em>"._("None defined")."</em>",$invalid_result);
} }
/** /**
@ -128,10 +161,9 @@ class m_variablesTest extends PHPUnit_Framework_TestCase
*/ */
public function testVariables_list_name() public function testVariables_list_name()
{ {
// Remove the following lines when you implement this test. $variables = $this->object->variables_list_name();
$this->markTestIncomplete( $this->assertTrue(is_array($variables));
'This test has not been implemented yet.' return $variables;
);
} }
/** /**
@ -140,9 +172,8 @@ class m_variablesTest extends PHPUnit_Framework_TestCase
*/ */
public function testVariables_list() public function testVariables_list()
{ {
// Remove the following lines when you implement this test. $variables = $this->object->variables_list();
$this->markTestIncomplete( $this->assertTrue(is_array($variables));
'This test has not been implemented yet.' return $variables;
);
} }
} }

View File

@ -1,156 +0,0 @@
<?php
/**
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:43:12.
*/
class m_variablesTest extends AlterncTest
{
function getConnection(){
}
function getDataSet(){
}
/**
* @var m_variables
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$this->object = new m_variables;
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown()
{
}
/**
* @covers m_variables::variable_init
* @todo Implement testVariable_init().
*/
public function testVariable_init()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::get_impersonated
* @todo Implement testGet_impersonated().
*/
public function testGet_impersonated()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::variable_init_maybe
* @todo Implement testVariable_init_maybe().
*/
public function testVariable_init_maybe()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::variable_get
* @todo Implement testVariable_get().
*/
public function testVariable_get()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::variable_update_or_create
* @todo Implement testVariable_update_or_create().
*/
public function testVariable_update_or_create()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::del
* @todo Implement testDel().
*/
public function testDel()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::display_valueraw_html
* @todo Implement testDisplay_valueraw_html().
*/
public function testDisplay_valueraw_html()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::display_value_html
* @todo Implement testDisplay_value_html().
*/
public function testDisplay_value_html()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::variables_list_name
* @todo Implement testVariables_list_name().
*/
public function testVariables_list_name()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers m_variables::variables_list
* @todo Implement testVariables_list().
*/
public function testVariables_list()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}