Browse Source

Added test for asserting flash messages before sending request

Jeremy Harris 7 years ago
parent
commit
4288e96c4d
1 changed files with 15 additions and 0 deletions
  1. 15 0
      tests/TestCase/TestSuite/IntegrationTestTraitTest.php

+ 15 - 0
tests/TestCase/TestSuite/IntegrationTestTraitTest.php

@@ -1185,6 +1185,21 @@ class IntegrationTestTraitTest extends IntegrationTestCase
     }
 
     /**
+     * Tests asserting flash messages without first sending a request
+     *
+     * @return void
+     */
+    public function testAssertFlashMessageWithoutSendingRequest()
+    {
+        $this->expectException(AssertionFailedError::class);
+        $message = 'There is no stored session data. Perhaps you need to run a request?';
+        $message .= ' Additionally, ensure `$this->enableRetainFlashMessages()` has been enabled for the test.';
+        $this->expectExceptionMessage($message);
+
+        $this->assertFlashMessage('Will not work');
+    }
+
+    /**
      * tests failure messages for assertions
      *
      * @param string $assertion Assertion method