getRequestQuery example

$request->server->set('REMOTE_ADDR', '127.0.0.1');
        $response = new Response('', 204);
        $collector = new RequestDataCollector();

        $profiler = new Profiler($this->storage);
        $profiler->add($collector);
        $profile = $profiler->collect($request$response);
        $profiler->saveProfile($profile);

        $this->assertSame(204, $profile->getStatusCode());
        $this->assertSame('GET', $profile->getMethod());
        $this->assertSame('bar', $profile->getCollector('request')->getRequestQuery()->all()['foo']->getValue());
    }

    public function testReset()
    {
        $collector = $this->getMockBuilder(DataCollectorInterface::class)
            ->onlyMethods(['collect', 'getName', 'reset'])
            ->getMock();
        $collector->expects($this->any())->method('getName')->willReturn('mock');
        $collector->expects($this->once())->method('reset');

        $profiler = new Profiler($this->storage);
        
$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());
        $this->assertEquals(['name' => 'foo']$c->getRouteParams());
        $this->assertSame([]$c->getSessionAttributes());
        $this->assertSame('en', $c->getLocale());
        $this->assertContainsEquals(__FILE__, $attributes->get('resource'));
        $this->assertSame('stdClass', $attributes->get('object')->getType());

        $this->assertInstanceOf(ParameterBag::class$c->getResponseHeaders());
        $this->assertSame('OK', $c->getStatusText());
        
 200, ['Content-Type' => 'text/html']);
    }

    /** * Returns the routing traces associated to the given request. */
    private function getTraces(RequestDataCollector $request, string $method): array
    {
        $traceRequest = Request::create(
            $request->getPathInfo(),
            $request->getRequestServer(true)->get('REQUEST_METHOD'),
            \in_array($request->getMethod()['DELETE', 'PATCH', 'POST', 'PUT'], true) ? $request->getRequestRequest()->all() : $request->getRequestQuery()->all(),
            $request->getRequestCookies(true)->all(),
            [],
            $request->getRequestServer(true)->all()
        );

        $context = $this->matcher->getContext();
        $context->setMethod($method);
        $matcher = new TraceableUrlMatcher($this->routes, $context);
        foreach ($this->expressionLanguageProviders as $provider) {
            $matcher->addExpressionLanguageProvider($provider);
        }

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