Remove misleading comment on the "Rename database" interface
[phpmyadmin/ammaryasirr.git] / test / PMA_showHint_test.php
blob2ff37fee99278c31d1b9f3c8169eba6029486fa5
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for showHint function
6 * @package phpMyAdmin-test
7 * @version $Id: PMA_showHint_test.php
8 */
10 /**
11 * Tests core.
13 require_once 'PHPUnit/Framework.php';
15 /**
16 * Include to test.
18 require_once './libraries/common.lib.php';
20 /**
21 * Test showHint function.
24 class PMA_showHint_test extends PHPUnit_Framework_TestCase
27 /**
28 * @var array temporary variable for globals array
30 protected $tmpGlobals;
32 /**
33 * @var array temporary variable for session array
35 protected $tmpSession;
37 /**
38 * storing globals and session
40 public function setUp()
42 $this->tmpGlobals = $GLOBALS;
43 $this->tmpSession = $_SESSION;
46 /**
47 * recovering globals and session
49 public function tearDown()
51 $GLOBALS = $this->tmpGlobals;
52 $_SESSION = $this->tmpSession;
55 /**
56 * PMA_showHint with defined GLOBALS
58 public function testShowHintReturnValue()
60 $key = md5('test');
61 $nr = 1234;
62 $instance = 1;
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'));
70 /**
71 * PMA_showHint with defined GLOBALS formatted as BB
73 public function testShowHintReturnValueBbFormat()
75 $key = md5('test');
76 $nr = 1234;
77 $instance = 1;
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));
85 /**
86 * PMA_showHint with not defined GLOBALS
88 public function testShowHintSetting()
90 $key = md5('test');
91 $nr = 1;
92 $instance = 1;
94 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
96 $expArray = array(
97 'note' => 'test',
98 'type' => 'notice',
99 'nr' => count($GLOBALS['footnotes']),
100 'instance' => 1,
103 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
107 * PMA_showHint with not defined GLOBALS formatted as BB
109 public function testShowHintSettingBbFormat()
111 $key = md5('test');
112 $nr = 1;
113 $instance = 1;
115 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
117 $expArray = array(
118 'note' => 'test',
119 'type' => 'notice',
120 'nr' => count($GLOBALS['footnotes']),
121 'instance' => 1,
124 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
128 * PMA_showHint with defined GLOBALS using PMA_Message object
130 public function testShowHintPmaMessageReturnValue()
132 $nr = 1;
133 $instance = 1;
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()
154 $nr = 1;
155 $instance = 1;
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();
166 $expArray = array(
167 'note' => $oMock,
168 'type' => $oMock->getLevel(),
169 'nr' => count($GLOBALS['footnotes']),
170 'instance' => 1,
173 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);