diff --git a/src/Controller/Component/SessionComponent.php b/src/Controller/Component/SessionComponent.php index a15d4918bd7..3cc303f5a6b 100644 --- a/src/Controller/Component/SessionComponent.php +++ b/src/Controller/Component/SessionComponent.php @@ -122,7 +122,7 @@ public function check($name) { * @link http://book.cakephp.org/2.0/en/core-libraries/components/sessions.html#creating-notification-messages */ public function setFlash($message, $element = 'default', array $params = array(), $key = 'flash') { - $this->write('Message.' . $key, compact('message', 'element', 'params')); + $this->_session->flash($message, 'info', $params + compact('element', 'key')); } /** diff --git a/tests/TestCase/Controller/Component/SessionComponentTest.php b/tests/TestCase/Controller/Component/SessionComponentTest.php index 6633d9b6516..680bcfa632f 100644 --- a/tests/TestCase/Controller/Component/SessionComponentTest.php +++ b/tests/TestCase/Controller/Component/SessionComponentTest.php @@ -171,18 +171,11 @@ public function testSessionFlash() { $this->assertNull($Session->read('Message.flash')); $Session->setFlash('This is a test message'); - $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.flash')); - - $Session->setFlash('This is a test message', 'test', array('name' => 'Joel Moss')); - $this->assertEquals(array('message' => 'This is a test message', 'element' => 'test', 'params' => array('name' => 'Joel Moss')), $Session->read('Message.flash')); - - $Session->setFlash('This is a test message', 'default', array(), 'myFlash'); - $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.myFlash')); - - $Session->setFlash('This is a test message', 'non_existing_layout'); - $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.myFlash')); - - $Session->delete('Message'); + $this->assertEquals(array( + 'message' => 'This is a test message', + 'params' => array('element' => 'default'), + 'type' => 'info' + ), $Session->read('Message.flash')); } /**