Skip to content

Commit

Permalink
Remove assertFlash()
Browse files Browse the repository at this point in the history
A few people have voiced concerns that it will feel unreliable as the
rendered view will not have flash messages to assert against. I would
rather we have fewer more stable asserts and avoid confusing/problematic
methods entirely.
  • Loading branch information
markstory committed Sep 12, 2014
1 parent c5370ea commit 03f9cf9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 25 deletions.
24 changes: 0 additions & 24 deletions src/TestSuite/IntegrationTestCase.php
Expand Up @@ -493,30 +493,6 @@ public function viewVariable($name) {
return null;
}

/**
* Assert that a flash message was set.
*
* @param string $type The flash type to check.
* @param string $content The flash message content to check.
* @param string $key The flash namespace the message is in.
* @param string $message The failure message that will be appended to the generated message.
* @return void
*/
public function assertFlash($type, $content, $key = 'flash', $message = '') {
if (empty($this->_requestSession)) {
$this->fail('There is no stored session data. Perhaps you need to run a request?');
}
$key = "Flash.{$key}";
if (!$this->_requestSession->check($key)) {
$this->fail("The {$key} key is not set in the session. " . $message);
}
$val = $this->_requestSession->read($key);
if (strpos($val['element'], $type) === false) {
$this->fail("The {$key} does not have a matching element/type of {$type}. " . $message);
}
$this->assertEquals($content, $val['message'], 'Flash message differs. ' . $message);
}

/**
* Assert session contents
*
Expand Down
1 change: 0 additions & 1 deletion tests/TestCase/TestSuite/IntegrationTestCaseTest.php
Expand Up @@ -99,7 +99,6 @@ public function testRequestSetsProperties() {
public function testFlashSessionAndCookieAsserts() {
$this->post('/posts/index');

$this->assertFlash('error', 'An error message');
$this->assertSession('An error message', 'Flash.flash.message');
$this->assertCookie(1, 'remember_me');
}
Expand Down

0 comments on commit 03f9cf9

Please sign in to comment.