HttpKernelBrowser example

use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpKernel\HttpKernelBrowser;
use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient;

/** * @group time-sensitive */
class HttpKernelBrowserTest extends TestCase
{
    public function testDoRequest()
    {
        $client = new HttpKernelBrowser(new TestHttpKernel());

        $client->request('GET', '/');
        $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
        $this->assertInstanceOf(\Symfony\Component\BrowserKit\Request::class$client->getInternalRequest());
        $this->assertInstanceOf(Request::class$client->getRequest());
        $this->assertInstanceOf(\Symfony\Component\BrowserKit\Response::class$client->getInternalResponse());
        $this->assertInstanceOf(Response::class$client->getResponse());

        $client->request('GET', 'http://www.example.com/');
        $this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
        $this->assertEquals('www.example.com', $client->getRequest()->getHost(), '->doRequest() uses the request handler to make the request');

        
Home | Imprint | This part of the site doesn't use cookies.