* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) * * Licensed under The MIT License * For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice * * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) * @link https://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests * @package Cake.Test.Case.View.Helper * @since CakePHP(tm) v 2.7.0-dev * @license https://opensource.org/licenses/mit-license.php MIT License */ App::uses('FlashHelper', 'View/Helper'); App::uses('View', 'View'); App::uses('CakePlugin', 'Core'); /** * FlashHelperTest class * * @package Cake.Test.Case.View.Helper */ class FlashHelperTest extends CakeTestCase { /** * setupBeforeClass method * * @return void */ public static function setupBeforeClass() { App::build(array( 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) )); } /** * setUp method * * @return void */ public function setUp() { parent::setUp(); $controller = null; $this->View = new View($controller); $this->Flash = new FlashHelper($this->View); if (!CakeSession::started()) { CakeSession::start(); } CakeSession::write(array( 'Message' => array( 'flash' => array( array( 'key' => 'flash', 'message' => 'This is the first Message', 'element' => 'Flash/default', 'params' => array() ), array( 'key' => 'flash', 'message' => 'This is the second Message', 'element' => 'Flash/default', 'params' => array() ) ), 'notification' => array( array( 'key' => 'notification', 'message' => 'Broadcast message testing', 'element' => 'flash_helper', 'params' => array( 'title' => 'Notice!', 'name' => 'Alert!' ) ) ), 'classy' => array( array( 'key' => 'classy', 'message' => 'Recorded', 'element' => 'flash_classy', 'params' => array() ) ), 'default' => array( array( 'key' => 'default', 'message' => 'Default', 'element' => 'default', 'params' => array() ) ) ) )); } /** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); unset($this->View, $this->Flash); CakeSession::destroy(); } /** * testFlash method * * @return void */ public function testFlash() { $result = $this->Flash->render(); $expected = '
'; $this->assertContains($expected, $result); $expected = 'Broadcast message testing
\nBroadcast message testing
\n