Answer the question
In order to leave comments, you need to log in
Phpunit in Symfony 4, change site url?
Good afternoon.
Trying to set up phpunit in symfony.
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'];
// ...
}
}
Answer the question
In order to leave comments, you need to log in
Try like this:
$client = self::createClient();
$client->setServerParameter('HTTP_HOST', 'symfony-test');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question