From daf6b06a0edbca331d36effdfb29d1e3acb4c869 Mon Sep 17 00:00:00 2001 From: Bryan Crowe Date: Mon, 9 Jun 2014 20:39:10 -0400 Subject: [PATCH] Remove flash string template and class option, update tests --- src/View/Helper/FlashHelper.php | 19 +---------- .../TestCase/View/Helper/FlashHelperTest.php | 33 ++----------------- .../TestApp/Template/Element/flash_classy.ctp | 1 + 3 files changed, 5 insertions(+), 48 deletions(-) create mode 100644 tests/test_app/TestApp/Template/Element/flash_classy.ctp diff --git a/src/View/Helper/FlashHelper.php b/src/View/Helper/FlashHelper.php index 703d31f725a..e70ed1e1886 100644 --- a/src/View/Helper/FlashHelper.php +++ b/src/View/Helper/FlashHelper.php @@ -26,19 +26,6 @@ */ class FlashHelper extends Helper { - use StringTemplateTrait; - -/** - * Default config for this class - * - * @var array - */ - protected $_defaultConfig = [ - 'templates' => [ - 'flash' => '
{{message}}
' - ] - ]; - /** * Used to render the message set in FlashComponent::set() * @@ -95,11 +82,7 @@ public function render($key = 'flash', $attrs = []) { $flash = array_merge($flash, $attrs); if ($flash['element'] === null) { - return $this->formatTemplate('flash', [ - 'key' => $key, - 'class' => $flash['class'], - 'message' => $flash['message'] - ]); + return $flash['message']; } return $this->_View->element($flash['element'], $flash); diff --git a/tests/TestCase/View/Helper/FlashHelperTest.php b/tests/TestCase/View/Helper/FlashHelperTest.php index 89784ecdfbf..3b8fdc14d7a 100644 --- a/tests/TestCase/View/Helper/FlashHelperTest.php +++ b/tests/TestCase/View/Helper/FlashHelperTest.php @@ -47,14 +47,12 @@ public function setUp() { 'key' => 'flash', 'message' => 'This is a calling', 'element' => null, - 'class' => 'info', 'params' => array() ), 'notification' => array( 'key' => 'notification', 'message' => 'This is a test of the emergency broadcasting system', 'element' => 'flash_helper', - 'class' => 'info', 'params' => array( 'title' => 'Notice!', 'name' => 'Alert!' @@ -63,8 +61,7 @@ public function setUp() { 'classy' => array( 'key' => 'classy', 'message' => 'Recorded', - 'element' => null, - 'class' => 'positive', + 'element' => 'flash_classy', 'params' => array() ) ) @@ -90,21 +87,14 @@ public function tearDown() { */ public function testFlash() { $result = $this->Flash->render(); - $expected = '
This is a calling
'; + $expected = 'This is a calling'; $this->assertEquals($expected, $result); - $expected = '
Recorded
'; + $expected = '
Recorded
'; $result = $this->Flash->render('classy'); $this->assertEquals($expected, $result); $result = $this->Flash->render('notification'); - - $children = [ - ['tag' => 'h1', 'content' => 'Alert!'], - ['tag' => 'h3', 'content' => 'Notice!'], - ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system'] - ]; - $expected = [ 'tag' => 'div', 'id' => 'notificationLayout', @@ -121,17 +111,6 @@ public function testFlash() { $this->assertTag($expected, $result); } -/** - * test flash() with the attributes. - * - * @return void - */ - public function testFlashAttributes() { - $result = $this->Flash->render('flash', array('class' => 'crazy')); - $expected = '
This is a calling
'; - $this->assertEquals($expected, $result); - } - /** * test setting the element from the attrs. * @@ -143,12 +122,6 @@ public function testFlashElementInAttrs() { 'params' => array('title' => 'Notice!', 'name' => 'Alert!') )); - $children = [ - ['tag' => 'h1', 'content' => 'Alert!'], - ['tag' => 'h3', 'content' => 'Notice!'], - ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system'] - ]; - $expected = [ 'tag' => 'div', 'id' => 'notificationLayout', diff --git a/tests/test_app/TestApp/Template/Element/flash_classy.ctp b/tests/test_app/TestApp/Template/Element/flash_classy.ctp new file mode 100644 index 00000000000..bba64f7941e --- /dev/null +++ b/tests/test_app/TestApp/Template/Element/flash_classy.ctp @@ -0,0 +1 @@ +
\ No newline at end of file