public function ResponseTest::testIsRedirectRedirection

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTest.php, line 535

Class

ResponseTest

Namespace

Symfony\Component\HttpFoundation\Tests

Code

public function testIsRedirectRedirection() {
  foreach (array(
    301,
    302,
    303,
    307,
  ) as $code) {
    $response = new Response('', $code);
    $this
      ->assertTrue($response
      ->isRedirection());
    $this
      ->assertTrue($response
      ->isRedirect());
  }
  $response = new Response('', 304);
  $this
    ->assertTrue($response
    ->isRedirection());
  $this
    ->assertFalse($response
    ->isRedirect());
  $response = new Response('', 200);
  $this
    ->assertFalse($response
    ->isRedirection());
  $this
    ->assertFalse($response
    ->isRedirect());
  $response = new Response('', 404);
  $this
    ->assertFalse($response
    ->isRedirection());
  $this
    ->assertFalse($response
    ->isRedirect());
  $response = new Response('', 301, array(
    'Location' => '/good-uri',
  ));
  $this
    ->assertFalse($response
    ->isRedirect('/bad-uri'));
  $this
    ->assertTrue($response
    ->isRedirect('/good-uri'));
}