[HttpKernel] fixed regression introduced in 2.4 in the base DataCollector class. Added more unit tests coverage for the RequestDataCollector object.

This commit is contained in:
Hugo Hamon 2013-11-26 13:58:53 +01:00
parent a5408b0a2a
commit d1e5006df4
2 changed files with 20 additions and 16 deletions

View File

@ -53,6 +53,6 @@ abstract class DataCollector implements DataCollectorInterface, \Serializable
$this->valueExporter = new ValueExporter();
}
$this->valueExporter->exportValue($var);
return $this->valueExporter->exportValue($var);
}
}

View File

@ -31,21 +31,23 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
$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->assertEquals('en',$c->getLocale());
$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->assertSame('html', $c->getFormat());
$this->assertSame('foobar', $c->getRoute());
$this->assertSame(array('name' => 'foo'), $c->getRouteParams());
$this->assertSame(array(), $c->getSessionAttributes());
$this->assertSame('en', $c->getLocale());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag',$c->getResponseHeaders());
$this->assertEquals('OK',$c->getStatusText());
$this->assertEquals(200,$c->getStatusCode());
$this->assertEquals('application/json',$c->getContentType());
$this->assertInstanceOf('Symfony\Component\HttpFoundation\HeaderBag', $c->getResponseHeaders());
$this->assertSame('OK', $c->getStatusText());
$this->assertSame(200, $c->getStatusCode());
$this->assertSame('application/json', $c->getContentType());
}
/**
@ -138,7 +140,7 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
foreach ($controllerTests as $controllerTest) {
$this->injectController($c, $controllerTest[1], $request);
$c->collect($request, $response);
$this->assertEquals($controllerTest[2], $c->getController(), sprintf('Testing: %s', $controllerTest[0]));
$this->assertSame($controllerTest[2], $c->getController(), sprintf('Testing: %s', $controllerTest[0]));
}
}
@ -150,6 +152,8 @@ class RequestDataCollectorTest extends \PHPUnit_Framework_TestCase
$request = Request::create('http://test.com/foo?bar=baz');
$request->attributes->set('foo', 'bar');
$request->attributes->set('_route', 'foobar');
$request->attributes->set('_route_params', array('name' => 'foo'));
$response = new Response();
$response->setStatusCode(200);