Browse Source

Remove flash string template and class option, update tests

Bryan Crowe 11 years ago
parent
commit
daf6b06a0e

+ 1 - 18
src/View/Helper/FlashHelper.php

@@ -26,19 +26,6 @@ use Cake\View\View;
  */
 class FlashHelper extends Helper {
 
-	use StringTemplateTrait;
-
-/**
- * Default config for this class
- *
- * @var array
- */
-	protected $_defaultConfig = [
-		'templates' => [
-			'flash' => '<div id="{{key}}-message" class="message-{{class}}">{{message}}</div>'
-		]
-	];
-
 /**
  * Used to render the message set in FlashComponent::set()
  *
@@ -95,11 +82,7 @@ class FlashHelper extends Helper {
 		$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);

+ 3 - 30
tests/TestCase/View/Helper/FlashHelperTest.php

@@ -47,14 +47,12 @@ class FlashHelperTest extends TestCase {
 					'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 @@ class FlashHelperTest extends TestCase {
 				'classy' => array(
 					'key' => 'classy',
 					'message' => 'Recorded',
-					'element' => null,
-					'class' => 'positive',
+					'element' => 'flash_classy',
 					'params' => array()
 				)
 			)
@@ -90,21 +87,14 @@ class FlashHelperTest extends TestCase {
  */
 	public function testFlash() {
 		$result = $this->Flash->render();
-		$expected = '<div id="flash-message" class="message-info">This is a calling</div>';
+		$expected = 'This is a calling';
 		$this->assertEquals($expected, $result);
 
-		$expected = '<div id="classy-message" class="message-positive">Recorded</div>';
+		$expected = '<div id="classy-message">Recorded</div>';
 		$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',
@@ -122,17 +112,6 @@ class FlashHelperTest extends TestCase {
 	}
 
 /**
- * test flash() with the attributes.
- *
- * @return void
- */
-	public function testFlashAttributes() {
-		$result = $this->Flash->render('flash', array('class' => 'crazy'));
-		$expected = '<div id="flash-message" class="message-crazy">This is a calling</div>';
-		$this->assertEquals($expected, $result);
-	}
-
-/**
  * test setting the element from the attrs.
  *
  * @return void
@@ -143,12 +122,6 @@ class FlashHelperTest extends TestCase {
 			'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',

+ 1 - 0
tests/test_app/TestApp/Template/Element/flash_classy.ctp

@@ -0,0 +1 @@
+<div id="<?= $key ?>-message"><?= $message; ?></div>