getRedirectionsCount() public method

Get the number of redirections done on the last request
public getRedirectionsCount ( ) : integer
return integer
コード例 #1
0
ファイル: SocketTest.php プロジェクト: lortnus/zf1
 /**
  * Make sure redirections stop when limit is exceeded
  *
  */
 public function testMaxRedirectsExceeded()
 {
     $this->client->setUri($this->baseuri . 'testRedirections.php');
     // Set some parameters
     $this->client->setParameterGet('swallow', 'african');
     $this->client->setParameterPost('Camelot', 'A silly place');
     // Set lower max redirections
     // Try with strict redirections first
     $this->client->setConfig(array('strictredirects' => true, 'maxredirects' => 2));
     $res = $this->client->request('POST');
     $this->assertTrue($res->isRedirect(), "Last response was not a redirection as expected. Response code: {$res->getStatus()}. Redirections counter: {$this->client->getRedirectionsCount()} (when strict redirects are on)");
     // Then try with normal redirections
     $this->client->setParameterGet('redirection', '0');
     $this->client->setConfig(array('strictredirects' => false));
     $res = $this->client->request('POST');
     $this->assertTrue($res->isRedirect(), "Last response was not a redirection as expected. Response code: {$res->getStatus()}. Redirections counter: {$this->client->getRedirectionsCount()} (when strict redirects are off)");
 }