3 require_once 'libraries/Theme.class.php';
6 * Test class for PMA_Theme.
7 * Generated by PHPUnit on 2011-07-18 at 03:19:13.
9 class PMA_ThemeTest
extends PHPUnit_Extensions_OutputTestCase
17 * Sets up the fixture, for example, opens a network connection.
18 * This method is called before a test is executed.
20 protected function setUp()
22 $this->object = new PMA_Theme
;
26 * Tears down the fixture, for example, closes a network connection.
27 * This method is called after a test is executed.
29 protected function tearDown()
33 public function testCheckImgPathNotExisted()
35 $this->object->setPath('path/to/nowhere');
36 $this->assertFalse($this->object->loadInfo());
39 public function testCheckImgPathIncorrect()
41 $this->object->setPath('./test/classes/_data/incorrect_theme');
42 $this->assertFalse($this->object->loadInfo(), 'Theme name is not properly set');
45 public function testCheckImgPathFull()
47 $this->object->setPath('./test/classes/_data/gen_version_info');
48 $this->assertTrue($this->object->loadInfo());
49 $this->assertEquals('Test Theme', $this->object->getName());
50 $this->assertEquals('2.0.3', $this->object->getVersion());
53 public function testLoadInfo()
55 $this->object->setPath('./themes/original');
56 $this->assertTrue($this->object->loadInfo());
58 $this->assertEquals(filemtime($this->object->getPath().'/info.inc.php'), $this->object->mtime_info
);
60 $this->object->setPath('./themes/original');
61 $this->object->mtime_info
= filemtime($this->object->getPath().'/info.inc.php');
62 $this->assertTrue($this->object->loadInfo());
63 $this->assertEquals('Original', $this->object->getName());
66 public function testLoad()
68 $newTheme = PMA_Theme
::load('./themes/original');
69 $this->assertNotNull($newTheme);
72 public function testLoadNotExisted()
74 $this->assertFalse(PMA_Theme
::load('/path/to/nowhere'));
78 * @expectedException PHPUnit_Framework_Error
80 public function testCheckImgPathBad()
82 $prevConfPath = $GLOBALS['cfg']['ThemePath'];
83 $GLOBALS['cfg']['ThemePath'] = 'nowhere';
84 $this->object->setPath('path/to/nowhere');
86 $this->object->checkImgPath();
89 public function testCheckImgPath()
91 $this->object->setPath('./themes/original');
92 $this->assertTrue($this->object->checkImgPath());
95 public function testCheckImgPathGlobals()
97 $this->object->setPath('/this/is/wrong/path');
98 $GLOBALS['cfg']['ThemePath'] = 'themes';
99 $this->assertTrue($this->object->checkImgPath());
103 * @expectedException PHPUnit_Framework_Error
105 public function testCheckImgPathGlobalsWrongPath()
107 $prevThemePath = $GLOBALS['cfg']['ThemePath'];
108 $GLOBALS['cfg']['ThemePath'] = 'no_themes';
110 $this->object->setPath('/this/is/wrong/path');
111 $this->object->checkImgPath();
113 $GLOBALS['cfg']['ThemePath'] = $prevThemePath;
117 * @covers PMA_Theme::setPath
118 * @covers PMA_Theme::getPath
120 public function testGetSetPath()
122 $this->assertEmpty($this->object->getPath());
123 $this->object->setPath('./themes/original');
125 $this->assertEquals('./themes/original', $this->object->getPath());
128 public function testGetLayoutFile()
130 $this->assertContains('layout.inc.php', $this->object->getLayoutFile());
134 * @depends testLoadInfo
136 public function testGetSetCheckVersion()
138 $this->assertEquals('0.0.0.0', $this->object->getVersion(), 'Version 0.0.0.0 by default');
140 $this->object->setVersion("1.2.3.4");
141 $this->assertEquals('1.2.3.4', $this->object->getVersion());
143 $this->assertFalse($this->object->checkVersion("0.0.1.1"));
144 $this->assertTrue($this->object->checkVersion("2.0.1.1"));
148 * @covers PMA_Theme::getName
149 * @covers PMA_Theme::setName
151 public function testGetSetName()
153 $this->assertEmpty($this->object->getName(), 'Name is empty by default');
154 $this->object->setName('New Theme Name');
156 $this->assertEquals('New Theme Name', $this->object->getName());
160 * @covers PMA_Theme::getId
161 * @covers PMA_Theme::setId
163 public function testGetSetId()
165 $this->assertEmpty($this->object->getId(), 'ID is empty by default');
166 $this->object->setId('NewID');
168 $this->assertEquals('NewID', $this->object->getId());
172 * @covers PMA_Theme::getImgPath
173 * @covers PMA_Theme::setImgPath
175 public function testGetSetImgPath()
177 $this->assertEmpty($this->object->getImgPath(), 'ImgPath is empty by default');
178 $this->object->setImgPath('/new/path');
180 $this->assertEquals('/new/path', $this->object->getImgPath());
183 public function testLoadCssWrongType()
186 $this->assertFalse($this->object->loadCss($type));
189 public function testLoadCssNotExisted()
192 $this->assertFalse($this->object->loadCss($type));
196 * @todo Implement testPrintPreview().
198 public function testPrintPreview()
200 // Remove the following lines when you implement this test.
201 $this->markTestIncomplete(
202 'This test has not been implemented yet.'