* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\RedirectResponse; class RedirectResponseTest extends TestCase { public function testGenerateMetaRedirect() { $response = new RedirectResponse('foo.bar'); $this->assertEquals(1, preg_match( '##', preg_replace(array('/\s+/', '/\'/'), array(' ', '"'), $response->getContent()) )); } /** * @expectedException \InvalidArgumentException */ public function testRedirectResponseConstructorNullUrl() { $response = new RedirectResponse(null); } /** * @expectedException \InvalidArgumentException */ public function testRedirectResponseConstructorWrongStatusCode() { $response = new RedirectResponse('foo.bar', 404); } public function testGenerateLocationHeader() { $response = new RedirectResponse('foo.bar'); $this->assertTrue($response->headers->has('Location')); $this->assertEquals('foo.bar', $response->headers->get('Location')); } public function testGetTargetUrl() { $response = new RedirectResponse('foo.bar'); $this->assertEquals('foo.bar', $response->getTargetUrl()); } public function testSetTargetUrl() { $response = new RedirectResponse('foo.bar'); $response->setTargetUrl('baz.beep'); $this->assertEquals('baz.beep', $response->getTargetUrl()); } /** * @expectedException \InvalidArgumentException */ public function testSetTargetUrlNull() { $response = new RedirectResponse('foo.bar'); $response->setTargetUrl(null); } public function testCreate() { $response = RedirectResponse::create('foo', 301); $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response); $this->assertEquals(301, $response->getStatusCode()); } public function testCacheHeaders() { $response = new RedirectResponse('foo.bar', 301); $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); $response = new RedirectResponse('foo.bar', 301, array('cache-control' => 'max-age=86400')); $this->assertFalse($response->headers->hasCacheControlDirective('no-cache')); $this->assertTrue($response->headers->hasCacheControlDirective('max-age')); $response = new RedirectResponse('foo.bar', 302); $this->assertTrue($response->headers->hasCacheControlDirective('no-cache')); } } __halt_compiler();----SIGNATURE:----M4AMsIzkW3PI2JZ1J/SX+usoti8F5Lovg4dYW6y977jldIjwK2chROz0I8UBwVwQ0xcM1tbXPJpyZIGQ8DyrAmM6RbkRavE+A5AUXmrIEwwraw0CF8x6h+lPGSXM4DRLc915bhH4DmyIVIkJkTq03Xpj6ufh3TsTb82COMzfna/oqI0r4/JkQpSSlgFaEJTKvW7hJYKh5Bj/eLg0KmL+nQX+RK/7a/OvXsr+YXYZBX0aS5eKq2EdEak9lsgmQW3hl5inR3DwNtpRj/+27SozOeSg/nMcc2Z8ZmrVe2wLe/7xUy3DGTWrwe+xN/OoOOVq2zPWET5fOeDST7HzAoR4GNNlm849bPVTWiL1MoyrYnV2mGg/WXHBHXyIZOx/fjhFn9fAdRjHGewH+0Hyzg6FRZkTH0rgEBBOfBmrMxjnBjsbDFJfSvhodVKT1fOYW305h+/9u6pzgaYrVDGoJljDFTGihRVUXAY1ZD1ebFXDeAVVIN1YNd98x7voGYPyDP8nDayaSOv76+ssmoTZ/x8wjUjo39lfzQYB7MjdfxdfDjW7Wnu9Gvvf2ex+fGF9GYSWWC+AC+G1Xl7ReBYB3wxf4v7716l7YPypeM51NBrM3VZJtBeTK8k02PEatmFRyE2O/31NyqPM/xdFbgmmRFzqglHyU6NZauzUkXCIXdVHXAY=----ATTACHMENT:----Njg0NDQ0MTIxMzg4NjYzMyA4MzYyOTI1NjYzNDMyMzc1IDM4MTY3ODQxOTk1MTU5MzI=