I am trying to understand what is wrong with my functional testing or project settings: running phpunit just prints the following information (I do not print this in the test suite, i.e. it is not from client-> getResponse () or anything else). In addition, the entire test immediately stops without any information about the results after this text is printed on the command line:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="refresh" content="1;url=/" /> <title>Redirecting to /</title> </head> <body> Redirecting to <a href="/">/</a>. </body> </html>
After running phpunit from the command line:
phpunit -c app --group temp1 src/AppBundle/Tests/Controller/SecurityControllerTest.php
My test code is pretty simple:
class SecurityControllerTest extends WebTestCase { /** * test login with succesfull case * * @group login * @group temp1 */ public function testLogin_success() { $client = static::createClient(); $crawler = $client->request('GET', '/'); // temp - just to test that the initial crawler location is correct $this->assertGreaterThan(0, $crawler->filter('html:contains("System Login")')->count(), "login page not found"); $client->followRedirects(true); $crawler = $this->loginSubmit($client, $crawler, " basic_user1@email.com ", "basic_user1_password"); // THE BELOW ROWS ARE NEVER REACHED // test that the user can access the user home $crawler = $client->request('GET', '/user/myprofile'); $this->assertGreaterThan(0, $crawler->filter('html:contains("Welcome to your user profile")')->count(), "User homepage not accessible after login"); } private function loginSubmit($client, $crawler, $username, $password) { $loginButton = $crawler->selectButton('Login'); $loginForm = $loginButton->form(); $loginForm['form[email]'] = $username; $loginForm['form[password]'] = $password; // BELOW IS THE ROW THAT RESULTS IN THE PRINTOUT + TEST EXECUTION STOP return $client->submit($loginForm); } //.... }
In addition, the exact same test script works fine in another project that I am working on, so I try to dig up differences in project configurations, etc. no luck.
Any help is greatly appreciated - feel free to ask for some other code / contents of the configuration file if this may be useful / relevant.
using symfony 2.3.12 and phpunit 4.1.0
UPDATED: specific code chain that leads to error
So, after you decided to work around this problem by solving a couple of problems associated with the project a couple of days ago, I returned to debug this problem a little more. And at present it seems that the result is due to the following code chain, first calling forward:
$this->forward('bundle:controller:action')->send();
and in a redirected call to the redirected controller:
$this->redirect($this->generateUrl($route, $parameters))->send();
Obviously, this regulator flow seems a little strange in general, but the question remains, why does this lead to the observed result?