}
/**
- * @dataProvider getFormatToMimeTypeMapProvider
+ * @dataProvider getFormatToMimeTypeMapProviderWithAdditionalNullFormat
*/
public function testGetFormatFromMimeType($format, $mimeTypes)
{
}
}
+ public function getFormatToMimeTypeMapProviderWithAdditionalNullFormat()
+ {
+ return array_merge(
+ array(array(null, array(null, 'unexistent-mime-type'))),
+ $this->getFormatToMimeTypeMapProvider()
+ );
+ }
+
public function testGetFormatFromMimeTypeWithParameters()
{
$request = new Request();
$this->assertEquals('json', $request->getFormat('application/json; charset=utf-8'));
}
+ /**
+ * @dataProvider getFormatToMimeTypeMapProvider
+ */
+ public function testGetMimeTypeFromFormat($format, $mimeTypes)
+ {
+ $request = new Request();
+ $this->assertEquals($mimeTypes[0], $request->getMimeType($format));
+ }
+
+ /**
+ * @dataProvider getFormatToMimeTypeMapProvider
+ */
+ public function testGetMimeTypesFromFormat($format, $mimeTypes)
+ {
+ $this->assertEquals($mimeTypes, Request::getMimeTypes($format));
+ }
+
+ public function testGetMimeTypesFromInexistentFormat()
+ {
+ $request = new Request();
+ $this->assertNull($request->getMimeType('foo'));
+ $this->assertEquals(array(), Request::getMimeTypes('foo'));
+ }
+
public function testGetFormatWithCustomMimeType()
{
$request = new Request();
public function getFormatToMimeTypeMapProvider()
{
return array(
- array(null, array(null, 'unexistent-mime-type')),
array('txt', array('text/plain')),
array('js', array('application/javascript', 'application/x-javascript', 'text/javascript')),
array('css', array('text/css')),
$this->assertEquals('/', $request->getPathInfo());
}
+ public function testGetParameterPrecedence()
+ {
+ $request = new Request();
+ $request->attributes->set('foo', 'attr');
+ $request->query->set('foo', 'query');
+ $request->request->set('foo', 'body');
+
+ $this->assertSame('attr', $request->get('foo'));
+
+ $request->attributes->remove('foo');
+ $this->assertSame('query', $request->get('foo'));
+
+ $request->query->remove('foo');
+ $this->assertSame('body', $request->get('foo'));
+
+ $request->request->remove('foo');
+ $this->assertNull($request->get('foo'));
+ }
+
public function testGetPreferredLanguage()
{
$request = new Request();
$request = new Request();
$this->assertNull($request->setRequestFormat('foo'));
$this->assertEquals('foo', $request->getRequestFormat(null));
+
+ $request = new Request(array('_format' => 'foo'));
+ $this->assertEquals('html', $request->getRequestFormat());
}
public function testHasSession()
);
}
+ /**
+ * @dataProvider methodIdempotentProvider
+ */
+ public function testMethodIdempotent($method, $idempotent)
+ {
+ $request = new Request();
+ $request->setMethod($method);
+ $this->assertEquals($idempotent, $request->isMethodIdempotent());
+ }
+
+ public function methodIdempotentProvider()
+ {
+ return array(
+ array('HEAD', true),
+ array('GET', true),
+ array('POST', false),
+ array('PUT', true),
+ array('PATCH', false),
+ array('DELETE', true),
+ array('PURGE', true),
+ array('OPTIONS', true),
+ array('TRACE', true),
+ array('CONNECT', false),
+ );
+ }
+
/**
* @dataProvider methodSafeProvider
*/
);
}
+ /**
+ * @group legacy
+ * @expectedDeprecation Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is deprecated since version 3.2 and will throw an exception in 4.0. Disable checking only for cacheable methods by calling the method with `false` as first argument or use the Request::isMethodCacheable() instead.
+ */
public function testMethodSafeChecksCacheable()
{
$request = new Request();