Common strings for descriptions of DATE, TIME, DATETIME and VARCHAR2
[phpmyadmin.git] / test / PMA_showHint_test.php
blobf0d1deec5527e18d7cb5226928128cf70b0a6983
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for PMA_showHint() function from common.lib.php
6 * @package PhpMyAdmin-test
7 * @version $Id: PMA_showHint_test.php
8 */
10 /**
11 * Include to test.
13 require_once 'libraries/common.lib.php';
15 class PMA_showHint_test extends PHPUnit_Framework_TestCase
18 /**
19 * @var array temporary variable for globals array
21 protected $tmpGlobals;
23 /**
24 * @var array temporary variable for session array
26 protected $tmpSession;
28 /**
29 * storing globals and session
31 public function setUp()
33 $this->tmpGlobals = $GLOBALS;
34 $this->tmpSession = $_SESSION;
37 /**
38 * recovering globals and session
40 public function tearDown()
42 $GLOBALS = $this->tmpGlobals;
43 $_SESSION = $this->tmpSession;
46 /**
47 * PMA_showHint with defined GLOBALS
49 public function testShowHintReturnValue()
51 $key = md5('test');
52 $nr = 1234;
53 $instance = 1;
55 $GLOBALS['footnotes'][$key]['nr'] = $nr;
56 $GLOBALS['footnotes'][$key]['instance'] = $instance;
57 $this->assertEquals(
58 sprintf(
59 '<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
60 $nr, $instance + 1, $nr
62 PMA_showHint('test')
66 /**
67 * PMA_showHint with defined GLOBALS formatted as BB
69 public function testShowHintReturnValueBbFormat()
71 $key = md5('test');
72 $nr = 1234;
73 $instance = 1;
75 $GLOBALS['footnotes'][$key]['nr'] = $nr;
76 $GLOBALS['footnotes'][$key]['instance'] = $instance;
77 $this->assertEquals(
78 sprintf('[sup]%d[/sup]', $nr),
79 PMA_showHint('test', true)
83 /**
84 * PMA_showHint with not defined GLOBALS
86 public function testShowHintSetting()
88 $key = md5('test');
89 $nr = 1;
90 $instance = 1;
92 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
94 $expArray = array(
95 'note' => 'test',
96 'type' => 'notice',
97 'nr' => count($GLOBALS['footnotes']),
98 'instance' => 1,
101 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
105 * PMA_showHint with not defined GLOBALS formatted as BB
106 * @depends testShowHintSetting
108 public function testShowHintSettingBbFormat()
110 $key = md5('test');
111 $nr = 1;
112 $instance = 1;
114 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
116 $expArray = array(
117 'note' => 'test',
118 'type' => 'notice',
119 'nr' => count($GLOBALS['footnotes']),
120 'instance' => 1,
123 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
127 * PMA_showHint with defined GLOBALS using PMA_Message object
129 public function testShowHintPmaMessageReturnValue()
131 $nr = 1;
132 $instance = 1;
134 $oMock = $this->getMock(
135 'PMA_Message',
136 array('setMessage', 'setNumber', 'getHash', 'getLevel')
138 $oMock->setMessage('test');
139 $oMock->setNumber($nr);
141 $key = $oMock->getHash();
143 $GLOBALS['footnotes'][$key]['nr'] = $nr;
144 $GLOBALS['footnotes'][$key]['instance'] = $instance;
146 $this->assertEquals(
147 sprintf(
148 '<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
149 $nr, $instance + 1, $nr
151 PMA_showHint($oMock)
156 * PMA_showHint with not defined GLOBALS using PMA_Message object
158 public function testShowHintPmaMessageSetting()
160 $nr = 1;
161 $instance = 1;
163 $oMock = $this->getMock(
164 'PMA_Message',
165 array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber')
167 $oMock->setMessage('test');
168 $oMock->setNumber($nr);
170 $this->assertEquals(
171 sprintf(
172 '<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
173 $nr, $instance, $nr
175 PMA_showHint($oMock, false)
178 $key = $oMock->getHash();
180 $expArray = array(
181 'note' => $oMock,
182 'type' => $oMock->getLevel(),
183 'nr' => count($GLOBALS['footnotes']),
184 'instance' => 1,
187 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);