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;
57 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
58 $nr, $instance +
1, $nr), PMA_showHint('test'));
62 * PMA_showHint with defined GLOBALS formatted as BB
64 public function testShowHintReturnValueBbFormat()
70 $GLOBALS['footnotes'][$key]['nr'] = $nr;
71 $GLOBALS['footnotes'][$key]['instance'] = $instance;
72 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr),
73 PMA_showHint('test', true));
77 * PMA_showHint with not defined GLOBALS
79 public function testShowHintSetting()
85 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
90 'nr' => count($GLOBALS['footnotes']),
94 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
98 * PMA_showHint with not defined GLOBALS formatted as BB
99 * @depends testShowHintSetting
101 public function testShowHintSettingBbFormat()
107 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
112 'nr' => count($GLOBALS['footnotes']),
116 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
120 * PMA_showHint with defined GLOBALS using PMA_Message object
122 public function testShowHintPmaMessageReturnValue()
127 $oMock = $this->getMock('PMA_Message',
128 array('setMessage', 'setNumber', 'getHash', 'getLevel'));
129 $oMock->setMessage('test');
130 $oMock->setNumber($nr);
132 $key = $oMock->getHash();
134 $GLOBALS['footnotes'][$key]['nr'] = $nr;
135 $GLOBALS['footnotes'][$key]['instance'] = $instance;
137 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
138 $nr, $instance +
1, $nr), PMA_showHint($oMock));
142 * PMA_showHint with not defined GLOBALS using PMA_Message object
144 public function testShowHintPmaMessageSetting()
149 $oMock = $this->getMock('PMA_Message',
150 array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber'));
151 $oMock->setMessage('test');
152 $oMock->setNumber($nr);
154 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint($oMock, false));
156 $key = $oMock->getHash();
160 'type' => $oMock->getLevel(),
161 'nr' => count($GLOBALS['footnotes']),
165 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);