Added new message types: info, warning to MgsViewHelper. Added method withPrefix to add custom css prefix to message

This commit is contained in:
Anton Terekhov
2012-11-21 18:11:38 +04:00
parent e5a0df37fc
commit 6b9c076053
2 changed files with 63 additions and 10 deletions

View File

@ -58,7 +58,21 @@ class MsgViewHelperTest extends PHPUnit_Framework_TestCase
$this->assertSame(array('message' => 'error message', 'type' => 'error'), Session::get('MsgViewHelper'));
$this->assertNull(Session::get('test'));
}
public function testInfo()
{
$this->helper->info('info message');
$this->assertSame(array('message' => 'info message', 'type' => 'info'), Session::get('MsgViewHelper'));
$this->assertNull(Session::get('test'));
}
public function testWarning()
{
$this->helper->warning('warning message');
$this->assertSame(array('message' => 'warning message', 'type' => 'warning'), Session::get('MsgViewHelper'));
$this->assertNull(Session::get('test'));
}
public function testToString()
{
$this->helper->success('yeah');
@ -71,4 +85,17 @@ class MsgViewHelperTest extends PHPUnit_Framework_TestCase
$result = $this->helper->__toString();
$this->assertEmpty($result);
}
public function testToStringWithPrefix()
{
$this->helper->success('yeah');
$result = $this->helper->withPrefix('prefix')->__toString();
$this->assertSame('<div class="prefixsuccess">yeah</div>', $result);
}
public function testToStringEmptyWithPrefix()
{
$result = $this->helper->withPrefix('prefix')->__toString();
$this->assertEmpty($result);
}
}