How to make https requests in symfony2 functional test? How to make https requests in symfony2 functional test? php php

How to make https requests in symfony2 functional test?


Thanks to @WouterJ i changed my client creation from :

static::createClient();

to:

static::createClient(array(),array('HTTPS' => true));

it solved my problem.It turns out that I cant give HTTP_HOST and HTTPS parameters in client ->request. It should be determined while client creation.


I am using Symfony4 and this how I created my functional test. I have tested following code and it works fine.

namespace App\Tests\Controller;use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;class CategoryControllerTest extends WebTestCase{    public function testList()    {       $client = static::createClient();        $client->request('GET', '/category/list');       $this->assertEquals(200, $client->getResponse()->getStatusCode());    }}