PHPUnit The current node list is empty

后端 未结 1 714
夕颜
夕颜 2021-01-24 23:34

I am creating some functional tests to test my controller. I have 2 functions at the moment. 1 for loggin in and 1 for the entity life cycle.

both should run normally (

相关标签:
1条回答
  • 2021-01-25 00:04

    After some searching I found the answer here on stackoverflow.

    The symfony2 crawler, by default, guesses that the location of server is at "localhost". Yet mine is not there. So I had to tell the crawler where to look.

    This is the code I had to add 'HTTP_HOST' => 'my.server.location'

    Adding this code makes the code look like this:

    $this->client = static::createClient( 
         array(),
         array(
            'HTTP_HOST' => 'my.server.location', //dependent on server        
        ));
    $this->client->followRedirects(true);
    

    So now when I get the url $crawler = $client->request('GET', '/admin/login');, The crawler will get the following url: http://my.server.location/admin/login.

    Hope this helps anyone!

    And credits to Matt for the answer

    0 讨论(0)
提交回复
热议问题