E
E
Evgeny Romashkan2018-07-05 13:23:44
symfony
Evgeny Romashkan, 2018-07-05 13:23:44

Phpunit in Symfony 4, change site url?

Good afternoon.
Trying to set up phpunit in symfony.

Standard test from documentation:
namespace App\Tests;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class ApplicationAvailabilityFunctionalTest extends WebTestCase
{
    /**
     * @dataProvider urlProvider
     */
    public function testPageIsSuccessful($url)
    {
        $client = self::createClient();
        $client->request('GET', $url);

        $this->assertTrue($client->getResponse()->isSuccessful());
    }

    public function urlProvider()
    {
        yield ['/'];
        yield ['/posts'];
        yield ['/post/fixture-post-1'];
        yield ['/blog/category/fixture-category'];
        yield ['/archives'];
        // ...
    }
}
accesses the address localhost/...
How can I set the first part of the address to be not "localhost" but "symfony-site.test"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
voronkovich, 2018-07-05
@EvgeniiR

Try like this:

$client = self::createClient();

$client->setServerParameter('HTTP_HOST', 'symfony-test');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question