there can be only ONE assert*() method in each test*() method
This commit is contained in:
@@ -26,148 +26,141 @@ class PMA_showHint_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* temporary variable for globals array
|
||||
* @var array temporary variable for globals array
|
||||
*/
|
||||
|
||||
protected $tmpGlobals;
|
||||
|
||||
/**
|
||||
* temporary variable for session array
|
||||
* @var array temporary variable for session array
|
||||
*/
|
||||
|
||||
protected $tmpSession;
|
||||
|
||||
/**
|
||||
* storing globals and session
|
||||
*/
|
||||
public function setUp() {
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->tmpGlobals = $GLOBALS;
|
||||
$this->tmpSession = $_SESSION;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* recovering globals and session
|
||||
*/
|
||||
public function tearDown() {
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
$GLOBALS = $this->tmpGlobals;
|
||||
$_SESSION = $this->tmpSession;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_showHint with defined GLOBALS
|
||||
*/
|
||||
|
||||
public function testShowHintWithGlobals() {
|
||||
|
||||
public function testShowHintReturnValue()
|
||||
{
|
||||
$key = md5('test');
|
||||
$nr = 1234;
|
||||
$instance = 1;
|
||||
|
||||
$GLOBALS['footnotes'][$key]['nr'] = $nr;
|
||||
$GLOBALS['footnotes'][$key]['instance'] = $instance;
|
||||
$this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance+1, $nr), PMA_showHint('test'));
|
||||
|
||||
$this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
|
||||
$nr, $instance + 1, $nr), PMA_showHint('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_showHint with defined GLOBALS formatted as BB
|
||||
*/
|
||||
|
||||
public function testShowHintWithGlobalsBbFormat() {
|
||||
|
||||
public function testShowHintReturnValueBbFormat()
|
||||
{
|
||||
$key = md5('test');
|
||||
$nr = 1234;
|
||||
$instance = 1;
|
||||
|
||||
$GLOBALS['footnotes'][$key]['nr'] = $nr;
|
||||
$GLOBALS['footnotes'][$key]['instance'] = $instance;
|
||||
$this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true));
|
||||
|
||||
$this->assertEquals(sprintf('[sup]%d[/sup]', $nr),
|
||||
PMA_showHint('test', true));
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_showHint with not defined GLOBALS
|
||||
*/
|
||||
|
||||
public function testShowHintWithoutGlobals() {
|
||||
|
||||
public function testShowHintSetting()
|
||||
{
|
||||
$key = md5('test');
|
||||
$nr = 1;
|
||||
$instance = 1;
|
||||
|
||||
$this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint('test', false, 'notice'));
|
||||
PMA_showHint('test', false, 'notice');
|
||||
|
||||
$expArray = array(
|
||||
'note' => 'test',
|
||||
'type' => 'notice',
|
||||
'nr' => count($GLOBALS['footnotes']),
|
||||
'instance' => 1
|
||||
'instance' => 1,
|
||||
);
|
||||
|
||||
$this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_showHint with not defined GLOBALS formatted as BB
|
||||
*/
|
||||
|
||||
public function testShowHintWithoutGlobalsBbFormat() {
|
||||
|
||||
public function testShowHintSettingBbFormat()
|
||||
{
|
||||
$key = md5('test');
|
||||
$nr = 1;
|
||||
$instance = 1;
|
||||
|
||||
$this->assertEquals(sprintf('[sup]%d[/sup]', $nr), PMA_showHint('test', true, 'notice'));
|
||||
PMA_showHint('test', true, 'notice');
|
||||
|
||||
$expArray = array(
|
||||
'note' => 'test',
|
||||
'type' => 'notice',
|
||||
'nr' => count($GLOBALS['footnotes']),
|
||||
'instance' => 1
|
||||
'instance' => 1,
|
||||
);
|
||||
|
||||
$this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_showHint with defined GLOBALS using PMA_Message object
|
||||
*/
|
||||
|
||||
public function testShowHintPmaMessageWithGlobals() {
|
||||
|
||||
public function testShowHintPmaMessageReturnValue()
|
||||
{
|
||||
$nr = 1;
|
||||
$instance = 1;
|
||||
|
||||
$oMock = $this->getMock('PMA_Message', array('setMessage', 'setNumber', 'getHash', 'getLevel'));
|
||||
$oMock = $this->getMock('PMA_Message',
|
||||
array('setMessage', 'setNumber', 'getHash', 'getLevel'));
|
||||
$oMock->setMessage('test');
|
||||
$oMock->setNumber($nr);
|
||||
|
||||
$key = $oMock->getHash();
|
||||
|
||||
$GLOBALS['footnotes'][$key]['nr'] = $nr;
|
||||
$GLOBALS['footnotes'][$key]['instance'] = $instance;
|
||||
|
||||
$this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance+1, $nr), PMA_showHint($oMock));
|
||||
$this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>',
|
||||
$nr, $instance + 1, $nr), PMA_showHint($oMock));
|
||||
}
|
||||
|
||||
/**
|
||||
* PMA_showHint with not defined GLOBALS using PMA_Message object
|
||||
*/
|
||||
|
||||
public function testShowHintPmaMessageWithoutGlobals() {
|
||||
|
||||
public function testShowHintPmaMessageSetting()
|
||||
{
|
||||
$nr = 1;
|
||||
$instance = 1;
|
||||
|
||||
$oMock = $this->getMock('PMA_Message', array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber'));
|
||||
$oMock = $this->getMock('PMA_Message',
|
||||
array('setMessage', 'setNumber', 'getHash', 'getLevel', 'getNumber'));
|
||||
$oMock->setMessage('test');
|
||||
$oMock->setNumber($nr);
|
||||
|
||||
$this->assertEquals(sprintf('<sup class="footnotemarker" id="footnote_sup_%d_%d">%d</sup>', $nr, $instance, $nr), PMA_showHint($oMock, false));
|
||||
PMA_showHint($oMock, false);
|
||||
|
||||
$key = $oMock->getHash();
|
||||
|
||||
@@ -175,11 +168,10 @@ class PMA_showHint_test extends PHPUnit_Framework_TestCase
|
||||
'note' => $oMock,
|
||||
'type' => $oMock->getLevel(),
|
||||
'nr' => count($GLOBALS['footnotes']),
|
||||
'instance' => 1
|
||||
'instance' => 1,
|
||||
);
|
||||
|
||||
$this->assertEquals($expArray, $GLOBALS['footnotes'][$key]);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user