2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Test for showHint function
6 * @author Michal Biniek <michal@bystrzyca.pl>
7 * @package phpMyAdmin-test
8 * @version $Id: PMA_showHint_test.php
14 require_once 'PHPUnit/Framework.php';
19 require_once './libraries/common.lib.php';
22 * Test showHint function.
25 class PMA_showHint_test
extends PHPUnit_Framework_TestCase
29 * @var array temporary variable for globals array
31 protected $tmpGlobals;
34 * @var array temporary variable for session array
36 protected $tmpSession;
39 * storing globals and session
41 public function setUp()
43 $this->tmpGlobals
= $GLOBALS;
44 $this->tmpSession
= $_SESSION;
48 * recovering globals and session
50 public function tearDown()
52 $GLOBALS = $this->tmpGlobals
;
53 $_SESSION = $this->tmpSession
;
57 * PMA_showHint with defined GLOBALS
59 public function testShowHintReturnValue()
65 $GLOBALS['footnotes'][$key]['nr'] = $nr;
66 $GLOBALS['footnotes'][$key]['instance'] = $instance;
67 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
68 $nr, $instance +
1, $nr), PMA_showHint('test'));
72 * PMA_showHint with defined GLOBALS formatted as BB
74 public function testShowHintReturnValueBbFormat()
80 $GLOBALS['footnotes'][$key]['nr'] = $nr;
81 $GLOBALS['footnotes'][$key]['instance'] = $instance;
82 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr),
83 PMA_showHint('test', true));
87 * PMA_showHint with not defined GLOBALS
89 public function testShowHintSetting()
95 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
100 'nr' => count($GLOBALS['footnotes']),
104 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
108 * PMA_showHint with not defined GLOBALS formatted as BB
110 public function testShowHintSettingBbFormat()
116 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
121 'nr' => count($GLOBALS['footnotes']),
125 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
129 * PMA_showHint with defined GLOBALS using PMA_Message object
131 public function testShowHintPmaMessageReturnValue()
136 $oMock = $this->getMock('PMA_Message',
137 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(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
147 $nr, $instance +
1, $nr), PMA_showHint($oMock));
151 * PMA_showHint with not defined GLOBALS using PMA_Message object
153 public function testShowHintPmaMessageSetting()
158 $oMock = $this->getMock('PMA_Message',
159 array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber'));
160 $oMock->setMessage('test');
161 $oMock->setNumber($nr);
163 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint($oMock, false));
165 $key = $oMock->getHash();
169 'type' => $oMock->getLevel(),
170 'nr' => count($GLOBALS['footnotes']),
174 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);