Home>
If there is no specific value in the controller, there is a place that redirects with a flash message
I want to check the flash that should return if there is no variable value in this part
Error messageSession content for "Flash.flash.0.message" differs.
Failed asserting that null matches expected 'Invalid request.'.</Code></pre>
<strong>Applicable source code</strong>
<pre><code>public function testPayCheckSalonId ($Id = null)
{
// Can error message and reductive processing be done only when there is no
$this->enableRetainFlashMessages ();
$this->post ('/ payments/pay /'. $Id);
$this->assertSession ('Invalid request.', 'Flash.flash.0.message');
}
Original controller
public function pay ($Id = null) {
if (empty ($Id)) {
$this->Flash->error (__ ('Invalid request.'));
return $this->redirect ($this->referer ());
}
}
I also rewritten the following format
$Id = '';
if (empty ($Id)) {
$this->enableRetainFlashMessages ();
$this->post ('/ payments/pay /'. $Id);
$this->assertSession ('Invalid request.', 'Flash.flash.0.message');
}
This is the same error as the first
$Id = '';
if (empty ($Id)) {
$this->enableRetainFlashMessages ();
$this->post ('/ payments/pay /'. $Id);
$this->assertFlashElement ('Flash/error');
}
I was angry that there was no method here
Error: Call to undefined method App \ Test \ TestCase \ Controller \ PaymentsControllerTest :: assertFlashElement ()
How can I check if a flash message has been issued?
Supplemental information (FW/tool version etc.)cakephp version 3.5
Execution environment local (MAMP)
-
Answer # 1
Related articles
- c ++ - c language: please tell me how to deal with the error message "bus error"!
- c++ - about gui error message management
- python 3x - i updated pip with python and it succeeded but i got an error message
- how to create a custom error message in laravel
- php - an error message that cannot be read by wordpress is displayed
- java - how to display error message when inputting non-integer
- i get an error message when i try to compile
- [ruby on rails] i want to add a word to the error message
- python 3x - i want to send an error message saying that it can not be used when i execute it to a person who can not use the com
- python 3x - i want to check the title of the message sender and execute it if i have the authority, and play it if i do not have
- i want to display a validation error message for pages with the same list and posting function
- php - how to delete wordpress error message
- blockchain - i get an error message when deploying solidity contract in the remix ide
- how to issue error message in ruby on rails
- c - i want to eliminate the error message
- i would like to know how to check the error of floating point and be careful
- vuejs - when i install axios on nuxt, i get an error message
- ruby - the intermediate table is used, and the error message of unknown column is displayed
- error message from mysql when opening laravel app
- nodejs - i'm not sure how to read gulp's error message
Related questions
- mysql - the controller unit test always returns a 500 error and i don't know the cause
- cakephp - how to test an exception occurrence case in a unit test of a controller linked with an external api
- mysql - about unit test of controller in cakephp3
- how to use constphp constants in cakephp3 controller unit tests
- how to write test code for phpunit
- can i load multiple components with phpunit?
- about errors when running tests with phpunit
- testing with cakephp3
- i'm having trouble with cakephp3 using phpunit
Because this method must be a logged-in user, the request was sent without having that information in the session, so the flash message of the target location was not reached