* @link http://netmonsters.ru * @package Majestic * @subpackage UnitTests * @since 2011-10-11 * * Unit tests for PHPView class */ require_once dirname(__FILE__) . '/../../../session/Session.php'; require_once dirname(__FILE__) . '/../../../view/iView.php'; require_once dirname(__FILE__) . '/../../../view/PHPView.php'; require_once dirname(__FILE__) . '/../../../view/helpers/ViewHelper.php'; require_once dirname(__FILE__) . '/../../../view/helpers/MsgViewHelper.php'; class MsgViewHelperTest extends PHPUnit_Framework_TestCase { public $helper; public function setUp() { Session::del('MsgViewHelper'); $this->helper = new MsgViewHelper(new PHPView(array('path' => 'any'))); } public function testMsg() { $this->helper->msg('new message from test', 'success'); $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(array('message' => 'error message', 'type' => 'error'), Session::get('MsgViewHelper')); } /** * @expectedException Exception * @expectedExceptionMessage Unknown message type */ public function testWrongType() { $this->helper->msg('some message', 'wrong'); } public function testSuccess() { $this->helper->success('success message'); $this->assertSame(array('message' => 'success message', 'type' => 'success'), Session::get('MsgViewHelper')); } public function testError() { $this->helper->error('error message'); $this->assertSame(array('message' => 'error message', 'type' => 'error'), Session::get('MsgViewHelper')); $this->assertNull(Session::get('test')); } public function testToString() { $this->helper->success('yeah'); $result = $this->helper->__toString(); $this->assertSame('