Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
m_variablesTest Class Reference

Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:59. More...

+ Inheritance diagram for m_variablesTest:

Public Member Functions

 getDataSet ()
 
 testVariable_init ($variables)
 m_variables::variable_init testGet_impersonated More...
 
 testGet_impersonated ()
 m_variables::get_impersonated More...
 
 testVariable_init_maybe ()
 m_variables::variable_init_maybe More...
 
 testVariable_get ()
 m_variables::variable_get More...
 
 testVariable_getOldWay ()
 m_variables::variable_get More...
 
 testVariable_getNewWayString ()
 m_variables::variable_get More...
 
 testVariable_getNewWayArray ()
 m_variables::variable_get More...
 
 testVariable_create_exception ()
 m_variables::variable_update_or_create More...
 
 testVariable_create ()
 m_variables::variable_update_or_create More...
 
 testVariable_update ()
 m_variables::variable_update_or_create More...
 
 testDel ()
 m_variables::del More...
 
 testDisplay_valueraw_html ()
 m_variables::display_valueraw_html More...
 
 testDisplay_value_html ($variables)
 m_variables::display_value_html testVariables_list More...
 
 testVariables_list_name ()
 m_variables::variables_list_name More...
 
 testVariables_list ()
 m_variables::variables_list More...
 
 getConnection ()
 
 loadDataSet ($fileList)
 

Protected Member Functions

 setUp ()
 Sets up the fixture, for example, opens a network connection. More...
 
 tearDown ()
 Tears down the fixture, for example, closes a network connection. More...
 

Protected Attributes

 $object
 

Detailed Description

Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-03-13 at 15:55:59.

Definition at line 5 of file m_variablesTest.php.

Member Function Documentation

AlterncTest::getConnection ( )
inherited
Returns
PHPUnit_Extensions_Database_DB_IDatabaseConnection

Definition at line 11 of file AlterncTest.php.

References $database, $password, and $user.

Referenced by m_actionTest\testArchive(), m_actionTest\testCancel(), m_actionTest\testChmod(), m_actionTest\testCreate_dir(), m_actionTest\testCreate_file(), m_actionTest\testDel(), testDel(), m_actionTest\testFinish(), m_actionTest\testFix_dir(), m_actionTest\testFix_file(), m_actionTest\testFix_user(), m_actionTest\testMove(), m_actionTest\testPurge(), m_actionTest\testReset_job(), m_actionTest\testSet(), testVariable_create(), and testVariable_update().

12  {
13  global $database,$user,$password;
14  $pdo = new PDO('mysql:dbname='.$database.';host=127.0.0.1',$user,$password);
15  return $this->createDefaultDBConnection($pdo);
16  }
$user
Definition: bootstrap.php:84
foreach(array(ALTERNC_MAIL, ALTERNC_HTML, ALTERNC_LOGS) as $crdir) $database
Definition: bootstrap.php:83
$password
Definition: bootstrap.php:85
m_variablesTest::getDataSet ( )
Returns
PHPUnit_Extensions_Database_DataSet_IDataSet

Definition at line 15 of file m_variablesTest.php.

References $list.

16  {
17  $list = array(
18  "testVariable_getNewWayArray" => "variables-empty.yml",
19  "testVariable_getNewWayString" => "variables-empty.yml",
20  "testVariable_getOldWay" => "variables-empty.yml",
21  "default" => "variables.yml"
22  );
23  if (isset($list[$this->getName()])) {
24  $dataset_file = $list[$this->getName()];
25  } else {
26  $dataset_file = "variables.yml";
27  }
28  return parent::loadDataSet($dataset_file);
29 
30  }
$list
Show a list of all found log files for an account and allow to see / tail / download them...
Definition: logs_list.php:30
AlterncTest::loadDataSet (   $fileList)
inherited
Parameters
string$fileList
Returns
Exceptions
Exception

Definition at line 24 of file AlterncTest.php.

References PHPUNIT_DATASETS_PATH.

Referenced by m_actionTest\testPurge(), and testVariable_update().

25  {
26  if (empty($fileList)) {
27  throw new \Exception("No files specified");
28  }
29  if( !is_array($fileList)){
30  $fileList = array($fileList);
31  }
32  $datasetList = array();
33  foreach ($fileList as $file_name) {
34  $file = PHPUNIT_DATASETS_PATH."/$file_name";
35  if( !is_file($file) ){
36  throw new \Exception("missing $file");
37  }
38  $dataSet = new PHPUnit_Extensions_Database_DataSet_YamlDataSet($file);
39  $datasetList[] = $dataSet;
40  }
41  $compositeDataSet = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet($datasetList);
42  return $dataSet;
43  }
const PHPUNIT_DATASETS_PATH
Definition: bootstrap.php:20
m_variablesTest::setUp ( )
protected

Sets up the fixture, for example, opens a network connection.

This method is called before a test is executed.

Definition at line 36 of file m_variablesTest.php.

37  {
38  parent::setUp();
39  $this->object = new m_variables;
40  }
m_variablesTest::tearDown ( )
protected

Tears down the fixture, for example, closes a network connection.

This method is called after a test is executed.

Definition at line 46 of file m_variablesTest.php.

47  {
48  parent::tearDown();
49  }
m_variablesTest::testDel ( )

m_variables::del

Definition at line 163 of file m_variablesTest.php.

References AlterncTest\getConnection().

164  {
165  $result = $this->object->del(999);
166  $this->assertTrue($result);
167  $this->assertEquals(0, $this->getConnection()->getRowCount('variable'));
168  }
m_variablesTest::testDisplay_value_html (   $variables)

m_variables::display_value_html testVariables_list

Definition at line 194 of file m_variablesTest.php.

References $variables.

195  {
196  $valid_result = $this->object->display_value_html($variables, "DEFAULT", 0, "phpunit",FALSE);
197  $this->assertStringMatchesFormat("phpunit",$valid_result);
198 
199  $invalid_result = $this->object->display_value_html($variables, "DEFAULT", 0, "phpunit-absent",FALSE);
200  $this->assertStringMatchesFormat("<em>"._("None defined")."</em>",$invalid_result);
201 
202  }
$variables
Definition: bootstrap.php:146
m_variablesTest::testDisplay_valueraw_html ( )

m_variables::display_valueraw_html

Definition at line 173 of file m_variablesTest.php.

References null.

174  {
175  // Empty string
176  $empty_result = $this->object->display_valueraw_html(null, "phpunit",FALSE);
177  $this->assertStringMatchesFormat("<em>"._("Empty")."</em>",$empty_result);
178  // Empty array
179  $empty_array_result = $this->object->display_valueraw_html(array(), "phpunit",FALSE);
180  $this->assertStringMatchesFormat("<em>"._("Empty array")."</em>",$empty_array_result);
181  // String
182  $value_result = $this->object->display_valueraw_html("value", "phpunit",FALSE);
183  $this->assertStringMatchesFormat($value_result,$value_result);
184  // String
185  $array_result = $this->object->display_valueraw_html(array("value","value"), "phpunit",FALSE);
186  $this->assertStringMatchesFormat("<ul>%s</ul>",$array_result);
187 
188  }
PR null
Definition: lang-css.js:1
m_variablesTest::testGet_impersonated ( )

m_variables::get_impersonated

Definition at line 65 of file m_variablesTest.php.

References $variables.

66  {
67  $variables = $this->object->get_impersonated();
68  return $variables;
69  }
$variables
Definition: bootstrap.php:146
m_variablesTest::testVariable_create ( )

m_variables::variable_update_or_create

Definition at line 137 of file m_variablesTest.php.

References AlterncTest\getConnection().

138  {
139  // Insert key with new key : success
140  $result = $this->object->variable_update_or_create("phpunit-success","phpunit","DEFAULT",0);
141  $this->assertTrue($result);
142  $this->assertEquals(2, $this->getConnection()->getRowCount('variable'));
143 
144  }
m_variablesTest::testVariable_create_exception ( )

m_variables::variable_update_or_create

Definition at line 128 of file m_variablesTest.php.

129  {
130  // Insert key with already existing key : success
131  $result = $this->object->variable_update_or_create("phpunit","phpunit-fail","DEFAULT",0);
132  }
m_variablesTest::testVariable_get ( )

m_variables::variable_get

Definition at line 83 of file m_variablesTest.php.

84  {
85  $result = $this->object->variable_get("phpunit");
86  $this->assertStringMatchesFormat("phpunit",$result);
87  }
m_variablesTest::testVariable_getNewWayArray ( )

m_variables::variable_get

Definition at line 116 of file m_variablesTest.php.

117  {
118  $phpunitArray = array("ns1"=>'ns1.tld',"ip"=>"1.2.3.4");
119  $this->object->variable_get('phpunit', $phpunitArray,'phpunit-comment', array("ns1"=>array('desc'=>'ns name','type'=>'string'),"ip"=>array("desc"=>"here an ip", "type"=>"ip")));
120  $result = $this->object->variable_get('phpunit');
121  $this->assertSame($phpunitArray,$result);
122  }
m_variablesTest::testVariable_getNewWayString ( )

m_variables::variable_get

Definition at line 104 of file m_variablesTest.php.

105  {
106 
107  // New way
108  $this->object->variable_get('phpunit', 'phpunit-default','comment', array('desc'=>'Want a string','type'=>'string'));
109  $result = $this->object->variable_get('phpunit');
110  $this->assertSame("phpunit-default",$result);
111  }
m_variablesTest::testVariable_getOldWay ( )

m_variables::variable_get

Definition at line 92 of file m_variablesTest.php.

93  {
94 
95  $this->object->variable_get('phpunit', 'phpunit-default','phpunit-comment');
96  $result = $this->object->variable_get('phpunit');
97  $this->assertSame("phpunit-default",$result);
98 
99  }
m_variablesTest::testVariable_init (   $variables)

m_variables::variable_init testGet_impersonated

Definition at line 55 of file m_variablesTest.php.

References $conf.

56  {
57  $this->object->variable_init();
58  global $conf;
59  $this->assertTrue(is_array($conf));
60  }
if(!$admin->enabled) $conf
Manages global variables of AlternC.
m_variablesTest::testVariable_init_maybe ( )

m_variables::variable_init_maybe

Definition at line 74 of file m_variablesTest.php.

75  {
76  $this->object->variable_init_maybe();
77  $this->assertTrue( (is_array($this->object->cache_conf) && !empty($this->object->cache_conf)) );
78  }
m_variablesTest::testVariable_update ( )

m_variables::variable_update_or_create

Definition at line 149 of file m_variablesTest.php.

References AlterncTest\getConnection(), and AlterncTest\loadDataSet().

150  {
151  $result = $this->object->variable_update_or_create("phpunit","phpunit-updated","DEFAULT",0,999);
152  $this->assertTrue($result);
153  $this->assertEquals(1, $this->getConnection()->getRowCount('variable'));
154  $expectedTable = $this->loadDataSet("variables-updated.yml")->getTable("variable");
155  $currentTable = $this->getConnection()->createQueryTable('variable', 'SELECT * FROM variable');
156  $this->assertTablesEqual($expectedTable, $currentTable);
157 
158  }
loadDataSet($fileList)
Definition: AlterncTest.php:24
m_variablesTest::testVariables_list ( )

m_variables::variables_list

Todo:
Implement testVariables_list().

Definition at line 219 of file m_variablesTest.php.

References $variables.

220  {
221  $variables = $this->object->variables_list();
222  $this->assertTrue(is_array($variables));
223  return $variables;
224  }
$variables
Definition: bootstrap.php:146
m_variablesTest::testVariables_list_name ( )

m_variables::variables_list_name

Todo:
Implement testVariables_list_name().

Definition at line 208 of file m_variablesTest.php.

References $variables.

209  {
210  $variables = $this->object->variables_list_name();
211  $this->assertTrue(is_array($variables));
212  return $variables;
213  }
$variables
Definition: bootstrap.php:146

Member Data Documentation

m_variablesTest::$object
protected

Definition at line 10 of file m_variablesTest.php.


The documentation for this class was generated from the following file: