aa[i/]test'),
array('[b]test[/b][strong]test[/strong]', 'testtest'),
array('[tt]test[/tt][code]test[/code]', 'testtest'),
array('[kbd]test[/kbd][br][sup]test[/sup]', 'test
test')
);
}
/**
* testing decodeBB method
* @dataProvider decodeBBDataProvider
*/
public function testDecodeBB($actual, $expected)
{
$this->assertEquals($expected, PMA_Message::decodeBB($actual));
}
/**
* testing format method
*/
public function testFormat()
{
$this->assertEquals('test string', PMA_Message::format('test string'));
$this->assertEquals('test string', PMA_Message::format('test string', 'a'));
$this->assertEquals('test string', PMA_Message::format('test string', array()));
$this->assertEquals('test string', PMA_Message::format('%s string', array('test')));
}
/**
* testing getHash method
*/
public function testGetHash()
{
$this->object->setString('<&>test', false);
$this->object->setMessage('<&>test', false);
$this->assertEquals(md5(PMA_Message::NOTICE . '<&>test<&>test'), $this->object->getHash());
}
/**
* getMessage test - with empty message and with non-empty string - not key in globals
* additional params are defined
*/
public function testGetMessageWithoutMessageWithStringWithParams()
{
$this->object->setMessage('');
$this->object->setString('test string %s %s');
$this->object->addParam('test param 1');
$this->object->addParam('test param 2');
$this->assertEquals('test string test param 1 test param 2', $this->object->getMessage());
}
/**
* getMessage test - with empty message and with empty string
*/
public function testGetMessageWithoutMessageWithEmptyString()
{
$this->object->setMessage('');
$this->object->setString('');
$this->assertEquals('', $this->object->getMessage());
}
/**
* getMessage test - with empty message and with string, which is key to GLOBALS
* additional messages are defined
*/
public function testGetMessageWithoutMessageWithGlobalStringWithAddMessages()
{
$GLOBALS['key'] = 'test message';
$this->object->setMessage('');
$this->object->setString('key');
$this->object->addMessage('test message 2', ' - ');
$this->object->addMessage('test message 3', '&');
$this->assertEquals('test message - test message 2&test message 3', $this->object->getMessage());
unset($GLOBALS['key']);
}
/**
* getMessage test - message is defined
* message with BBCode defined
*/
public function testGetMessageWithMessageWithBBCode()
{
$this->object->setMessage('[kbd]test[/kbd] [a@./Documentation.html#cfg_Example@_blank]test[/a]');
$this->assertEquals('test test', $this->object->getMessage());
}
/**
* getLevel test
*/
public function testGetLevel()
{
$this->assertEquals('notice', $this->object->getLevel());
$this->object->setNumber(PMA_Message::SUCCESS);
$this->assertEquals('success', $this->object->getLevel());
$this->object->setNumber(PMA_Message::ERROR);
$this->assertEquals('error', $this->object->getLevel());
}
/**
* testing display method (output string and _is_displayed varible)
*/
public function testDisplay()
{
$this->assertFalse($this->object->isDisplayed());
$this->object->setMessage('Test Message');
$this->expectOutputString('Test Message
');
$this->object->display();
$this->assertTrue($this->object->isDisplayed());
}
/**
* getDisplay test
*/
public function testGetDisplay()
{
$this->object->setMessage('Test Message');
$this->assertEquals('Test Message
', $this->object->getDisplay());
}
/**
* isDisplayed test
*/
public function testIsDisplayed()
{
$this->assertFalse($this->object->isDisplayed(false));
$this->assertTrue($this->object->isDisplayed(true));
$this->assertTrue($this->object->isDisplayed(false));
}
public function providerAffectedRows(){
return array(array(1, ' 1 row affected.
'));
return array(array(2, ' 2 rows affected.
'));
return array(array(50000000000000, ' 50000000000000 rows affected.
'));
}
/**
* affected_rows test
*
* @dataProvider providerAffectedRows
*/
public function testAffectedRows($rows, $output)
{
$this->object = new PMA_Message();
$msg = $this->object->affected_rows($rows);
echo $this->object->addMessage($msg);
$this->expectOutputString($output);
$this->object->display();
}
public function providerInsertedRows(){
return array(array(1, ' 1 row inserted.
'));
return array(array(2, ' 2 rows inserted.
'));
return array(array(50000000000000, ' 50000000000000 rows inserted.
'));
}
/**
* inserted_rows test
*
* @dataProvider providerInsertedRows
*/
public function testInsertedRows($rows, $output)
{
$this->object = new PMA_Message();
$msg = $this->object->inserted_rows($rows);
echo $this->object->addMessage($msg);
$this->expectOutputString($output);
$this->object->display();
}
public function providerDeletedRows(){
return array(array(1, ' 1 row deleted.
'));
return array(array(2, ' 2 rows deleted.
'));
return array(array(50000000000000, ' 50000000000000 rows deleted.
'));
}
/**
* deleted_rows test
*
* @dataProvider providerDeletedRows
*/
public function testDeletedRows($rows, $output)
{
$this->object = new PMA_Message();
$msg = $this->object->deleted_rows($rows);
echo $this->object->addMessage($msg);
$this->expectOutputString($output);
$this->object->display();
}
}
?>