Skip to content
Permalink
Browse files

Make SessionHelper more accepting of bad data.

The SessionHelper needs to gracefully accept data that does not match
its expectations. By setting all the keys we can avoid any potential
warnings.

Refs #3813
  • Loading branch information...
markstory committed Jun 26, 2014
1 parent 6105948 commit c468679f48852e18e62b1d4c26a21087d93f0d1b
Showing with 16 additions and 2 deletions.
  1. +2 −1 src/View/Helper/SessionHelper.php
  2. +14 −1 tests/TestCase/View/Helper/SessionHelperTest.php
@@ -123,8 +123,9 @@ public function flash($key = 'flash', $attrs = []) {
$this->request->session()->delete('Flash.' . $key);
if (!empty($attrs)) {
$flash = array_merge($flash, $attrs);
$flash = $attrs + $flash;
}
$flash += ['message' => '', 'type' => 'info', 'params' => []];
$message = $flash['message'];
$class = $flash['type'];
@@ -64,7 +64,10 @@ public function setUp() {
'type' => 'success',
'params' => array('class' => 'positive'),
'message' => 'Recorded'
)
),
'incomplete' => [
'message' => 'A thing happened',
]
),
'Deeply' => array('nested' => array('key' => 'value')),
));
@@ -129,6 +132,16 @@ public function testFlash() {
$this->assertFalse($this->Session->check('Message.notification'));
}
/**
* Test rendering a flash message for incomplete data.
*
* @return void
*/
public function testFlashIncomplete() {
$result = $this->Session->flash('incomplete');
$expected = '<div id="flash-message" class="message-info">A thing happened</div>';
}
/**
* test flash() with the attributes.
*

0 comments on commit c468679

Please sign in to comment.
You can’t perform that action at this time.