public function urlDoesNotRedirect($url)
    {
        if ('/' === $url) {
            $url = '';
        }

        // We must not follow all redirects, so save current situation,
        // force disable follow redirects, and revert at the end.
        $followsRedirects = $this->isFollowingRedirects();
        $this->followRedirects(false);

        $response       = $this->sendHeadAndGetResponse($url);

        if (null !== $response) {
            $responseCode   = $response->getStatus();
            $locationHeader = $response->getHeader('Location', true);

            // Check for 200 response code.
            $this->assertEquals(200, $responseCode, 'Response code was not 200.');

            // Check that destination URL does not try to redirect.
            // Somewhat redundant, as this should never appear with a 200 HTTP Status code anyway.
            $this->assertNull($locationHeader, 'Location header was found when it should not exist.');
        }

        $this->followRedirects($followsRedirects);
    }
public function urlDoesNotRedirect($url)
    {
        if ('/' === $url) {
            $url = '';
        }

        // We must not follow all redirects, so save current situation,
        // force disable follow redirects, and revert at the end.
        $followsRedirects = $this->isFollowingRedirects();
        $this->followRedirects(false);

        $response       = $this->sendHeadAndGetResponse($url);

        if (null !== $response) {
            $responseCode   = $response->getStatus();
            $locationHeader = $response->getHeader('Location', true);

            // Check for 200 response code.
            $this->assertEquals(200, $responseCode, 'Response code was not 200.');

            // Check that destination URL does not try to redirect.
            // Somewhat redundant, as this should never appear with a 200 HTTP Status code anyway.
            $this->assertNull($locationHeader, 'Location header was found when it should not exist.');
        }

        $this->followRedirects($followsRedirects);
    }
public function urlDoesNotRedirect ( $ url ) { if ( '/' === $ url ) { $ url = '' ; } // We must not follow all redirects, so save current situation, // force disable follow redirects, and revert at the end. $ followsRedirects = $ this -> isFollowingRedirects ( ) ; $ this -> followRedirects ( false ) ; $ response = $ this -> sendHeadAndGetResponse ( $ url ) ; if ( null !== $ response ) { $ responseCode = $ response -> getStatus ( ) ; $ locationHeader = $ response -> getHeader ( 'Location' , true ) ; // Check for 200 response code. $ this -> assertEquals ( 200 , $ responseCode , 'Response code was not 200.' ) ; // Check that destination URL does not try to redirect. // Somewhat redundant, as this should never appear with a 200 HTTP Status code anyway. $ this -> assertNull ( $ locationHeader , 'Location header was found when it should not exist.' ) ; } $ this -> followRedirects ( $ followsRedirects ) ; }
Check that a 200 HTTP Status is returned and the URL has no redirects.

@since 0.1.3
@since 0.2.0 Renamed method, made public.

@param string $url Relative or absolute URL of redirect destination.
Check that a 200 HTTP Status is returned and the URL has no redirects .