Fix FlashHelper::render() cannot render default messages

Fixes #9910
This commit is contained in:
chinpei215 2017-01-05 18:47:47 +09:00
parent 7e187a4e41
commit 94d9bcd674
2 changed files with 19 additions and 0 deletions

View file

@ -76,6 +76,12 @@ class FlashHelperTest extends CakeTestCase {
'message' => 'Recorded',
'element' => 'flash_classy',
'params' => array()
),
'default' => array(
'key' => 'default',
'message' => 'Default',
'element' => 'default',
'params' => array()
)
)
));
@ -154,4 +160,13 @@ class FlashHelperTest extends CakeTestCase {
$expected = 'this is the plugin element';
$this->assertContains($expected, $result);
}
/**
* Test that the default element fallbacks to the Flash/default element.
*/
public function testFlashFallback() {
$result = $this->Flash->render('default');
$expected = '<div class="message">Default</div>';
$this->assertContains($expected, $result);
}
}

View file

@ -86,6 +86,10 @@ class FlashHelper extends AppHelper {
CakeSession::delete("Message.$key");
$flash['key'] = $key;
if ($flash['element'] === 'default') {
$flash['element'] = 'Flash/default';
}
return $this->_View->element($flash['element'], $flash);
}
}