2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for showHint function
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_showHint_test.php
13 require_once 'PHPUnit/Framework.php';
18 require_once './libraries/common.lib.php';
21 * Test showHint function.
24 class PMA_showHint_test
extends PHPUnit_Framework_TestCase
28 * @var array temporary variable for globals array
30 protected $tmpGlobals;
33 * @var array temporary variable for session array
35 protected $tmpSession;
38 * storing globals and session
40 public function setUp()
42 $this->tmpGlobals
= $GLOBALS;
43 $this->tmpSession
= $_SESSION;
47 * recovering globals and session
49 public function tearDown()
51 $GLOBALS = $this->tmpGlobals
;
52 $_SESSION = $this->tmpSession
;
56 * PMA_showHint with defined GLOBALS
58 public function testShowHintReturnValue()
64 $GLOBALS['footnotes'][$key]['nr'] = $nr;
65 $GLOBALS['footnotes'][$key]['instance'] = $instance;
66 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
67 $nr, $instance +
1, $nr), PMA_showHint('test'));
71 * PMA_showHint with defined GLOBALS formatted as BB
73 public function testShowHintReturnValueBbFormat()
79 $GLOBALS['footnotes'][$key]['nr'] = $nr;
80 $GLOBALS['footnotes'][$key]['instance'] = $instance;
81 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr),
82 PMA_showHint('test', true));
86 * PMA_showHint with not defined GLOBALS
88 public function testShowHintSetting()
94 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
99 'nr' => count($GLOBALS['footnotes']),
103 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
107 * PMA_showHint with not defined GLOBALS formatted as BB
109 public function testShowHintSettingBbFormat()
115 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
120 'nr' => count($GLOBALS['footnotes']),
124 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
128 * PMA_showHint with defined GLOBALS using PMA_Message object
130 public function testShowHintPmaMessageReturnValue()
135 $oMock = $this->getMock('PMA_Message',
136 array('setMessage', 'setNumber', 'getHash', 'getLevel'));
137 $oMock->setMessage('test');
138 $oMock->setNumber($nr);
140 $key = $oMock->getHash();
142 $GLOBALS['footnotes'][$key]['nr'] = $nr;
143 $GLOBALS['footnotes'][$key]['instance'] = $instance;
145 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
146 $nr, $instance +
1, $nr), PMA_showHint($oMock));
150 * PMA_showHint with not defined GLOBALS using PMA_Message object
152 public function testShowHintPmaMessageSetting()
157 $oMock = $this->getMock('PMA_Message',
158 array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber'));
159 $oMock->setMessage('test');
160 $oMock->setNumber($nr);
162 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint($oMock, false));
164 $key = $oMock->getHash();
168 'type' => $oMock->getLevel(),
169 'nr' => count($GLOBALS['footnotes']),
173 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);