getRequestAttributes example

use Symfony\Component\HttpKernel\Tests\Fixtures\DataCollector\DummyController;

class RequestDataCollectorTest extends TestCase
{
    public function testCollect()
    {
        $c = new RequestDataCollector();

        $c->collect($request = $this->createRequest()$this->createResponse());
        $c->lateCollect();

        $attributes = $c->getRequestAttributes();

        $this->assertSame('request', $c->getName());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestHeaders());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestServer());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestCookies());
        $this->assertInstanceOf(ParameterBag::class$attributes);
        $this->assertInstanceOf(ParameterBag::class$c->getRequestRequest());
        $this->assertInstanceOf(ParameterBag::class$c->getRequestQuery());
        $this->assertInstanceOf(ParameterBag::class$c->getResponseCookies());
        $this->assertSame('html', $c->getFormat());
        $this->assertEquals('foobar', $c->getRoute());
        
->willReturn(true);

        return [$captcha];
    }

    private function getControllerEventMock(): ControllerEvent
    {
        return new ControllerEvent(
            $this->createMock(HttpKernelInterface::class),
            function D): void {
            },
            self::getRequest($this->getRequestAttributes(true)),
            HttpKernelInterface::MAIN_REQUEST
        );
    }

    private static function getRequest(ParameterBag $attributes): Request
    {
        return new Request([][]$attributes->all()[][][]);
    }

    private function getRequestAttributes(bool $isCheckEnabled): ParameterBag
    {
        
Home | Imprint | This part of the site doesn't use cookies.