Browse Source

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.
mark_story 11 years ago
parent
commit
03f9cf935b

+ 0 - 24
src/TestSuite/IntegrationTestCase.php

@@ -494,30 +494,6 @@ class IntegrationTestCase extends TestCase {
 	}
 
 /**
- * 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
  *
  * @param string $expected The expected contents.

+ 0 - 1
tests/TestCase/TestSuite/IntegrationTestCaseTest.php

@@ -99,7 +99,6 @@ class IntegrationTestCaseTest extends IntegrationTestCase {
 	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');
 	}