diff --git a/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php b/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php index 1d36810bb..2fea49113 100644 --- a/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/SessionHelperTest.php @@ -80,6 +80,7 @@ class SessionHelperTest extends CakeTestCase { public function tearDown() { $_SESSION = array(); unset($this->View, $this->Session); + CakePlugin::unload(); parent::tearDown(); } @@ -160,7 +161,7 @@ class SessionHelperTest extends CakeTestCase { */ public function testFlashElementInAttrs() { App::build(array( - 'views' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) + 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View'. DS) )); $result = $this->Session->flash('flash', array( 'element' => 'session_helper', @@ -168,4 +169,23 @@ class SessionHelperTest extends CakeTestCase { )); $expected = "
\n\t

Alert!

\n\t

Notice!

\n\t

This is a calling

\n
"; } + +/** + * test using eleents in plugins. + * + * @return void + */ + public function testFlashWithPluginElement() { + App::build(array( + 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS) + )); + CakePlugin::load('TestPlugin'); + + $result = $this->Session->flash('flash', array( + 'element' => 'plugin_element', + 'plugin' => 'TestPlugin' + )); + $expected = 'this is the plugin element using params[plugin]'; + $this->assertEquals($expected, $result); + } } diff --git a/lib/Cake/View/Helper/SessionHelper.php b/lib/Cake/View/Helper/SessionHelper.php index 696821921..23de503e0 100644 --- a/lib/Cake/View/Helper/SessionHelper.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -128,9 +128,13 @@ class SessionHelper extends AppHelper { } elseif ($flash['element'] == '' || $flash['element'] == null) { $out = $message; } else { + $options = array(); + if (isset($flash['plugin'])) { + $options['plugin'] = $flash['plugin']; + } $tmpVars = $flash['params']; $tmpVars['message'] = $message; - $out = $this->_View->element($flash['element'], $tmpVars); + $out = $this->_View->element($flash['element'], $tmpVars, $options); } CakeSession::delete('Message.' . $key); }