Russian update
[phpmyadmin/madhuracj.git] / test / PMA_showHint_test.php
blob1d87702deb90209849f15eafdf73729954a7cdba
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Test for showHint function
6 * @author Michal Biniek <michal@bystrzyca.pl>
7 * @package phpMyAdmin-test
8 * @version $Id: PMA_showHint_test.php
9 */
11 /**
12 * Tests core.
14 require_once 'PHPUnit/Framework.php';
16 /**
17 * Include to test.
19 require_once './libraries/common.lib.php';
21 /**
22 * Test showHint function.
25 class PMA_showHint_test extends PHPUnit_Framework_TestCase
28 /**
29 * @var array temporary variable for globals array
31 protected $tmpGlobals;
33 /**
34 * @var array temporary variable for session array
36 protected $tmpSession;
38 /**
39 * storing globals and session
41 public function setUp()
43 $this->tmpGlobals = $GLOBALS;
44 $this->tmpSession = $_SESSION;
47 /**
48 * recovering globals and session
50 public function tearDown()
52 $GLOBALS = $this->tmpGlobals;
53 $_SESSION = $this->tmpSession;
56 /**
57 * PMA_showHint with defined GLOBALS
59 public function testShowHintReturnValue()
61 $key = md5('test');
62 $nr = 1234;
63 $instance = 1;
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'));
71 /**
72 * PMA_showHint with defined GLOBALS formatted as BB
74 public function testShowHintReturnValueBbFormat()
76 $key = md5('test');
77 $nr = 1234;
78 $instance = 1;
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));
86 /**
87 * PMA_showHint with not defined GLOBALS
89 public function testShowHintSetting()
91 $key = md5('test');
92 $nr = 1;
93 $instance = 1;
95 $this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
97 $expArray = array(
98 'note' => 'test',
99 'type' => 'notice',
100 'nr' => count($GLOBALS['footnotes']),
101 'instance' => 1,
104 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
108 * PMA_showHint with not defined GLOBALS formatted as BB
110 public function testShowHintSettingBbFormat()
112 $key = md5('test');
113 $nr = 1;
114 $instance = 1;
116 $this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
118 $expArray = array(
119 'note' => 'test',
120 'type' => 'notice',
121 'nr' => count($GLOBALS['footnotes']),
122 'instance' => 1,
125 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
129 * PMA_showHint with defined GLOBALS using PMA_Message object
131 public function testShowHintPmaMessageReturnValue()
133 $nr = 1;
134 $instance = 1;
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()
155 $nr = 1;
156 $instance = 1;
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();
167 $expArray = array(
168 'note' => $oMock,
169 'type' => $oMock->getLevel(),
170 'nr' => count($GLOBALS['footnotes']),
171 'instance' => 1,
174 $this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);