Browse Source

replacement Exception() on InitializationException()

master
Vyacheslav Agafonov 13 years ago
parent
commit
82fb239fca
  1. 6
      tests/view/helpers/MsgViewHelperTest.php
  2. 2
      view/helpers/MsgViewHelper.php

6
tests/view/helpers/MsgViewHelperTest.php

@ -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()

2
view/helpers/MsgViewHelper.php

@ -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));
} }

Loading…
Cancel
Save