2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for PMA_showHint() function from common.lib.php
6 * @package PhpMyAdmin-test
7 * @version $Id: PMA_showHint_test.php
13 require_once 'libraries/common.lib.php';
15 class PMA_showHint_test
extends PHPUnit_Framework_TestCase
19 * @var array temporary variable for globals array
21 protected $tmpGlobals;
24 * @var array temporary variable for session array
26 protected $tmpSession;
29 * storing globals and session
31 public function setUp()
33 $this->tmpGlobals
= $GLOBALS;
34 $this->tmpSession
= $_SESSION;
38 * recovering globals and session
40 public function tearDown()
42 $GLOBALS = $this->tmpGlobals
;
43 $_SESSION = $this->tmpSession
;
47 * PMA_showHint with defined GLOBALS
49 public function testShowHintReturnValue()
55 $GLOBALS['footnotes'][$key]['nr'] = $nr;
56 $GLOBALS['footnotes'][$key]['instance'] = $instance;
59 '<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
60 $nr, $instance +
1, $nr
67 * PMA_showHint with defined GLOBALS formatted as BB
69 public function testShowHintReturnValueBbFormat()
75 $GLOBALS['footnotes'][$key]['nr'] = $nr;
76 $GLOBALS['footnotes'][$key]['instance'] = $instance;
78 sprintf('[sup]%d[/sup]', $nr),
79 PMA_showHint('test', true)
84 * PMA_showHint with not defined GLOBALS
86 public function testShowHintSetting()
92 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
97 'nr' => count($GLOBALS['footnotes']),
101 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
105 * PMA_showHint with not defined GLOBALS formatted as BB
106 * @depends testShowHintSetting
108 public function testShowHintSettingBbFormat()
114 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
119 'nr' => count($GLOBALS['footnotes']),
123 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
127 * PMA_showHint with defined GLOBALS using PMA_Message object
129 public function testShowHintPmaMessageReturnValue()
134 $oMock = $this->getMock(
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;
148 '<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
149 $nr, $instance +
1, $nr
156 * PMA_showHint with not defined GLOBALS using PMA_Message object
158 public function testShowHintPmaMessageSetting()
163 $oMock = $this->getMock(
165 array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber')
167 $oMock->setMessage('test');
168 $oMock->setNumber($nr);
172 '<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
175 PMA_showHint($oMock, false)
178 $key = $oMock->getHash();
182 'type' => $oMock->getLevel(),
183 'nr' => count($GLOBALS['footnotes']),
187 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);