Refactored ConfigFile class so that it is no longer a singleton
[phpmyadmin.git] / test / classes / PMA_List_Database_test.php
blob984069561e832ca78639d2d49fc6e037923b1853
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * tests for PMA_List_Database class
6 * @package PhpMyAdmin-test
7 */
9 /*
10 * Include to test.
12 require_once 'libraries/Util.class.php';
13 require_once 'libraries/List_Database.class.php';
14 require_once 'libraries/relation.lib.php';
16 /**
17 * tests for PMA_List_Database class
19 * @package PhpMyAdmin-test
21 class PMA_List_Database_Test extends PHPUnit_Framework_TestCase
23 /**
24 * SetUp for test cases
26 * @return void
28 public function setup()
30 $GLOBALS['cfg']['Server']['only_db'] = array('single\\_db');
31 $this->object = new PMA_List_Database();
34 /**
35 * Call protected functions by setting visibility to public.
37 * @param string $name method name
38 * @param array $params parameters for the invocation
40 * @return the output from the protected method.
42 private function _callProtectedFunction($name, $params)
44 $class = new ReflectionClass('PMA_List_Database');
45 $method = $class->getMethod($name);
46 $method->setAccessible(true);
47 return $method->invokeArgs($this->object, $params);
50 /**
51 * Test for PMA_List_Database::getEmpty
53 * @return void
55 public function testEmpty()
57 $arr = new PMA_List_Database;
58 $this->assertEquals('', $arr->getEmpty());
61 /**
62 * Test for PMA_List_Database::getSingleItem
64 * @return void
66 public function testSingle()
68 $arr = new PMA_List_Database;
69 $this->assertEquals('single_db', $arr->getSingleItem());
72 /**
73 * Test for PMA_List_Database::exists
75 * @return void
77 public function testExists()
79 $arr = new PMA_List_Database;
80 $this->assertEquals(true, $arr->exists('single_db'));
83 /**
84 * Test for PMA_List_Database::getHtmlOptions
86 * @return void
88 public function testHtmlOptions()
90 $arr = new PMA_List_Database;
91 $this->assertEquals(
92 '<option value="single_db">single_db</option>' . "\n",
93 $arr->getHtmlOptions()
97 /**
98 * Test for checkHideDatabase
100 * @return void
102 public function testCheckHideDatabase()
104 $GLOBALS['cfg']['Server']['hide_db'] = 'single\\_db';
105 $this->assertEquals(
106 $this->_callProtectedFunction(
107 'checkHideDatabase',
108 array()
115 * Test for getDefault
117 * @return void
119 public function testGetDefault()
121 $GLOBALS['db'] = '';
122 $this->assertEquals(
123 $this->object->getDefault(),
127 $GLOBALS['db'] = 'mysql';
128 $this->assertEquals(
129 $this->object->getDefault(),
130 'mysql'