forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThemeManagerTest.php
More file actions
155 lines (141 loc) · 3.48 KB
/
Copy pathThemeManagerTest.php
File metadata and controls
155 lines (141 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for ThemeManager class
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
use PMA\libraries\ThemeManager;
require_once 'test/PMATestCase.php';
/**
* tests for ThemeManager class
*
* @package PhpMyAdmin-test
*/
class ThemeManagerTest extends PMATestCase
{
/**
* SetUp for test cases
*
* @return void
*/
public function setup()
{
$GLOBALS['cfg']['ThemePerServer'] = false;
$GLOBALS['cfg']['ThemeDefault'] = 'pmahomme';
$GLOBALS['cfg']['ServerDefault'] = 0;
$GLOBALS['server'] = 99;
$GLOBALS['PMA_Config'] = new PMA\libraries\Config();
$GLOBALS['collation_connection'] = 'utf8_general_ci';
$dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->any())->method('escapeString')
->will($this->returnArgument(0));
$cfg['dbi'] = $dbi;
}
/**
* Test for ThemeManager::getThemeCookieName
*
* @return void
*/
public function testCookieName()
{
$tm = new ThemeManager();
$this->assertEquals('pma_theme', $tm->getThemeCookieName());
}
/**
* Test for ThemeManager::getThemeCookieName
*
* @return void
*/
public function testPerServerCookieName()
{
$tm = new ThemeManager();
$tm->setThemePerServer(true);
$this->assertEquals('pma_theme-99', $tm->getThemeCookieName());
}
/**
* Test for ThemeManager::getHtmlSelectBox
*
* @return void
*/
public function testHtmlSelectBox()
{
$tm = new ThemeManager();
$this->assertContains(
'<option value="pmahomme" selected="selected">',
$tm->getHtmlSelectBox()
);
}
/**
* Test for setThemeCookie
*
* @return void
*/
public function testSetThemeCookie()
{
$tm = new ThemeManager();
$this->assertTrue(
$tm->setThemeCookie()
);
}
/**
* Test for checkConfig
*
* @return void
*/
public function testCheckConfig()
{
$tm = new ThemeManager();
$this->assertNull(
$tm->checkConfig()
);
}
/**
* Test for makeBc
*
* @return void
*/
public function testMakeBc()
{
$tm = new ThemeManager();
$this->assertNull(
$tm->makeBc()
);
$this->assertEquals($GLOBALS['theme'], 'pmahomme');
$this->assertEquals($GLOBALS['pmaThemePath'], './themes/pmahomme');
$this->assertEquals($GLOBALS['pmaThemeImage'], './themes/pmahomme/img/');
}
/**
* Test for getPrintPreviews
*
* @return void
*/
public function testGetPrintPreviews()
{
$tm = new ThemeManager();
$preview = $tm->getPrintPreviews();
$this->assertContains('<div class="theme_preview"', $preview);
$this->assertContains('Original', $preview);
$this->assertContains('set_theme=original', $preview);
$this->assertContains('pmahomme', $preview);
$this->assertContains('set_theme=pmahomme', $preview);
}
/**
* Test for getFallBackTheme
*
* @return void
*/
public function testGetFallBackTheme()
{
$tm = new ThemeManager();
$this->assertInstanceOf(
'PMA\libraries\Theme',
$tm->getFallBackTheme()
);
}
}