Skip to content

Commit 03f9cf9

Browse files
committed
Remove assertFlash()
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.
1 parent c5370ea commit 03f9cf9

File tree

2 files changed

+0
-25
lines changed

2 files changed

+0
-25
lines changed

src/TestSuite/IntegrationTestCase.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -493,30 +493,6 @@ public function viewVariable($name) {
493493
return null;
494494
}
495495

496-
/**
497-
* Assert that a flash message was set.
498-
*
499-
* @param string $type The flash type to check.
500-
* @param string $content The flash message content to check.
501-
* @param string $key The flash namespace the message is in.
502-
* @param string $message The failure message that will be appended to the generated message.
503-
* @return void
504-
*/
505-
public function assertFlash($type, $content, $key = 'flash', $message = '') {
506-
if (empty($this->_requestSession)) {
507-
$this->fail('There is no stored session data. Perhaps you need to run a request?');
508-
}
509-
$key = "Flash.{$key}";
510-
if (!$this->_requestSession->check($key)) {
511-
$this->fail("The {$key} key is not set in the session. " . $message);
512-
}
513-
$val = $this->_requestSession->read($key);
514-
if (strpos($val['element'], $type) === false) {
515-
$this->fail("The {$key} does not have a matching element/type of {$type}. " . $message);
516-
}
517-
$this->assertEquals($content, $val['message'], 'Flash message differs. ' . $message);
518-
}
519-
520496
/**
521497
* Assert session contents
522498
*

tests/TestCase/TestSuite/IntegrationTestCaseTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public function testRequestSetsProperties() {
9999
public function testFlashSessionAndCookieAsserts() {
100100
$this->post('/posts/index');
101101

102-
$this->assertFlash('error', 'An error message');
103102
$this->assertSession('An error message', 'Flash.flash.message');
104103
$this->assertCookie(1, 'remember_me');
105104
}

0 commit comments

Comments
 (0)