Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PMA_Theme_Manager_test.php « classes « test - github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6d4042acf5794c89c74bd62c71ac7b8998304d87 (plain)
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
156
157
158
159
160
161
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * tests for PMA_Theme_Manager class
 *
 * @package PhpMyAdmin-test
 */

/*
 * Include to test.
 */
require_once 'libraries/Util.class.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Theme.class.php';
require_once 'libraries/Theme_Manager.class.php';
require_once 'libraries/Config.class.php';
require_once 'libraries/core.lib.php';

/**
 * tests for PMA_Theme_Manager class
 *
 * @package PhpMyAdmin-test
 */
class PMA_Theme_Manager_Test extends PHPUnit_Framework_TestCase
{
    /**
     * SetUp for test cases
     *
     * @return void
     */
    public function setup()
    {
        $GLOBALS['cfg']['ThemePath'] = './themes';
        $GLOBALS['cfg']['ThemePerServer'] = false;
        $GLOBALS['cfg']['ThemeDefault'] = 'pmahomme';
        $GLOBALS['cfg']['ServerDefault'] = 0;
        $GLOBALS['server'] = 99;
        $GLOBALS['PMA_Config'] = new PMA_Config();
        $GLOBALS['collation_connection'] = 'utf8_general_ci';
    }

    /**
     * Test for PMA_Theme_Manager::getThemeCookieName
     *
     * @return void
     */
    public function testCookieName()
    {
        $tm = new PMA_Theme_Manager();
        $this->assertEquals('pma_theme', $tm->getThemeCookieName());
    }

    /**
     * Test for PMA_Theme_Manager::getThemeCookieName
     *
     * @return void
     */
    public function testPerServerCookieName()
    {
        $tm = new PMA_Theme_Manager();
        $tm->setThemePerServer(true);
        $this->assertEquals('pma_theme-99', $tm->getThemeCookieName());
    }

    /**
     * Test for PMA_Theme_Manager::getHtmlSelectBox
     *
     * @return void
     */
    public function testHtmlSelectBox()
    {
        $tm = new PMA_Theme_Manager();
        $this->assertContains(
            '<option value="pmahomme" selected="selected">',
            $tm->getHtmlSelectBox()
        );
    }

    /**
     * Test for setThemeCookie
     *
     * @return void
     */
    public function testSetThemeCookie()
    {
        $tm = new PMA_Theme_Manager();
        $this->assertTrue(
            $tm->setThemeCookie()
        );
    }

    /**
     * Test for checkConfig
     *
     * @return void
     */
    public function testCheckConfig()
    {
        $tm = new PMA_Theme_Manager();
        $this->assertNull(
            $tm->checkConfig()
        );
    }

    /**
     * Test for makeBc
     *
     * @return void
     */
    public function testMakeBc()
    {
        $tm = new PMA_Theme_Manager();
        $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 PMA_Theme_Manager();
        $this->assertEquals(
            '<div class="theme_preview"><h2>Original (2.9) </h2><p><a class='
            . '"take_theme" name="original" href="index.php?set_theme=original'
            . '&amp;server=99&amp;lang=en&amp;collation_connection=utf8_general_ci'
            . '&amp;token=token"><img src="./themes/original/screen.png" border="1" '
            . 'alt="Original" title="Original" /><br />[ <strong>take it</strong> ]'
            . '</a></p></div><div class="theme_preview"><h2>pmahomme (1.1) </h2><p>'
            . '<a class="take_theme" name="pmahomme" href="index.php?set_theme='
            . 'pmahomme&amp;server=99&amp;lang=en&amp;collation_connection=utf8_'
            . 'general_ci&amp;token=token"><img src="./themes/pmahomme/screen.png" '
            . 'border="1" alt="pmahomme" title="pmahomme" /><br />[ <strong>take it'
            . '</strong> ]</a></p></div>',
            $tm->getPrintPreviews()
        );
    }

    /**
     * Test for getFallBackTheme
     *
     * @return void
     */
    public function testGetFallBackTheme()
    {
        $tm = new PMA_Theme_Manager();
        $this->assertInstanceOf(
            'PMA_theme',
            $tm->getFallBackTheme()
        );
    }
}
?>