public function testCollect() { $c = new RequestDataCollector(); $c->collect($request = $this->createRequest(), $this->createResponse()); $cloner = new VarCloner(); $attributes = $c->getRequestAttributes(); $this->assertSame('request', $c->getName()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getRequestHeaders()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestServer()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestCookies()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $attributes); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestRequest()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestQuery()); $this->assertSame('html', $c->getFormat()); $this->assertEquals('foobar', $c->getRoute()); $this->assertEquals($cloner->cloneVar(array('name' => 'foo')), $c->getRouteParams()); $this->assertSame(array(), $c->getSessionAttributes()); $this->assertSame('en', $c->getLocale()); $this->assertEquals($cloner->cloneVar($request->attributes->get('resource')), $attributes->get('resource')); $this->assertEquals($cloner->cloneVar($request->attributes->get('object')), $attributes->get('object')); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getResponseHeaders()); $this->assertSame('OK', $c->getStatusText()); $this->assertSame(200, $c->getStatusCode()); $this->assertSame('application/json', $c->getContentType()); }
/** * @dataProvider provider */ public function testCollect(Request $request, Response $response) { $c = new RequestDataCollector(); $c->collect($request, $response); $this->assertSame('request', $c->getName()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getRequestHeaders()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestServer()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestCookies()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestAttributes()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestRequest()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestQuery()); $this->assertEquals('html', $c->getFormat()); $this->assertEquals(array(), $c->getSessionAttributes()); $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getResponseHeaders()); $this->assertEquals(200, $c->getStatusCode()); $this->assertEquals('application/json', $c->getContentType()); }