Skip to content
Permalink
Browse files

Added test for asserting flash after they're rendered

  • Loading branch information...
jeremyharris committed May 5, 2017
1 parent 1995447 commit a33cb7f372ed74532714e070dcccc555c2bf6685
@@ -405,6 +405,20 @@ public function testFlashSessionAndCookieAssertsHttpServer()
$this->assertCookie(1, 'remember_me');
}
/**
* Test flash assertions stored with enableRememberFlashMessages() after they
* are rendered
*
* @return void
*/
public function testFlashAssertionsAfterRender()
{
$this->enableRememberFlashMessages();
$this->get('/posts/index/with_flash');
$this->assertSession('An error message', 'Flash.flash.0.message');
}
/**
* Tests the failure message for assertCookieNotSet
*
@@ -48,16 +48,18 @@ public function beforeFilter(Event $event)
/**
* Index method.
*
* @param string $layout
* @return void
*/
public function index()
public function index($layout = 'default')
{
$this->Flash->error('An error message');
$this->response->cookie([
'name' => 'remember_me',
'value' => 1
]);
$this->set('test', 'value');
$this->viewBuilder()->setLayout($layout);
}
/**
@@ -0,0 +1 @@
<div class="message"><?= h($message); ?></div>
@@ -0,0 +1,43 @@
<?php
$this->loadHelper('Html');
$cakeDescription = 'CakePHP: the rapid development php framework';
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?= $this->Html->charset(); ?>
<title>
<?= $cakeDescription ?>:
<?= $this->fetch('title'); ?>
</title>
<?php
echo $this->Html->meta('icon');
echo $this->Html->css('cake.generic');
echo $this->fetch('script');
?>
</head>
<body>
<div id="container">
<div id="header">
<h1><?= $this->Html->link($cakeDescription, 'http://cakephp.org'); ?></h1>
</div>
<div id="content">

<?= $this->Flash->render(); ?>
<?= $this->fetch('content'); ?>

</div>
<div id="footer">
<?= $this->Html->link(
$this->Html->image('cake.power.gif', ['alt' => $cakeDescription, 'border' => '0']),
'http://www.cakephp.org/',
['target' => '_blank', 'escape' => false]
);
?>
</div>
</div>
</body>
</html>

0 comments on commit a33cb7f

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