replacement Exception() on InitializationException()

This commit is contained in:
Vyacheslav Agafonov
2011-11-24 17:02:36 +04:00
parent eebb013ecf
commit 82fb239fca
2 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,7 @@ require_once dirname(__FILE__) . '/../../../view/iView.php';
require_once dirname(__FILE__) . '/../../../view/PHPView.php'; require_once dirname(__FILE__) . '/../../../view/PHPView.php';
require_once dirname(__FILE__) . '/../../../view/helpers/ViewHelper.php'; require_once dirname(__FILE__) . '/../../../view/helpers/ViewHelper.php';
require_once dirname(__FILE__) . '/../../../view/helpers/MsgViewHelper.php'; require_once dirname(__FILE__) . '/../../../view/helpers/MsgViewHelper.php';
require_once dirname(__FILE__) . '/../../../exception/InitializationException.php';
class MsgViewHelperTest extends PHPUnit_Framework_TestCase class MsgViewHelperTest extends PHPUnit_Framework_TestCase
{ {
@ -29,15 +30,18 @@ class MsgViewHelperTest extends PHPUnit_Framework_TestCase
public function testMsg() public function testMsg()
{ {
$this->helper->msg('new message from test', 'success'); $this->helper->msg('new message from test', 'success');
$this->assertSame(array('message' => 'new message from test', 'type' => 'success'), Session::get('MsgViewHelper')); $this->assertSame(array('message' => 'new message from test', 'type' => 'success'), Session::get('MsgViewHelper'));
$this->assertSame($this->helper, $this->helper->msg('error message', 'error')); $this->assertSame($this->helper, $this->helper->msg('error message', 'error'));
$this->assertSame(array('message' => 'error message', 'type' => 'error'), Session::get('MsgViewHelper')); $this->assertSame(array('message' => 'error message', 'type' => 'error'), Session::get('MsgViewHelper'));
} }
/** /**
* @expectedException Exception * @expectedException InitializationException
* @expectedExceptionMessage Unknown message type * @expectedExceptionMessage Unknown message type
*/ */
public function testWrongType() public function testWrongType()

View File

@ -21,7 +21,7 @@ class MsgViewHelper extends ViewHelper
{ {
if ($msg && $type) { if ($msg && $type) {
if (!in_array($type, array(self::SUCCESS, self::ERROR))) { if (!in_array($type, array(self::SUCCESS, self::ERROR))) {
throw new Exception('Unknown message type: "' . $type . '"'); throw new InitializationException('Unknown message type: "' . $type . '"');
} }
Session::set(__CLASS__, array('message' => $msg, 'type' => $type)); Session::set(__CLASS__, array('message' => $msg, 'type' => $type));
} }