Beispiel #1
0
 public function testRedirectsRequests()
 {
     $mock = new puzzle_subscriber_Mock();
     $history = new puzzle_subscriber_History();
     $mock->addMultiple(array("HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect1\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect2\r\nContent-Length: 0\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
     $client = new puzzle_Client(array('base_url' => 'http://test.com'));
     $client->getEmitter()->attach($history);
     $client->getEmitter()->attach($mock);
     $response = $client->get('/foo');
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertContains('/redirect2', $response->getEffectiveUrl());
     // Ensure that two requests were sent
     $requests = $history->getRequests();
     $this->assertEquals('/foo', $requests[0]->getPath());
     $this->assertEquals('GET', $requests[0]->getMethod());
     $this->assertEquals('/redirect1', $requests[1]->getPath());
     $this->assertEquals('GET', $requests[1]->getMethod());
     $this->assertEquals('/redirect2', $requests[2]->getPath());
     $this->assertEquals('GET', $requests[2]->getMethod());
 }
Beispiel #2
0
 /**
  * @expectedException OutOfBoundsException
  */
 public function testUpdateThrowsExceptionWhenEmpty()
 {
     $p = new puzzle_subscriber_Mock();
     $ev = new puzzle_event_BeforeEvent(new puzzle_adapter_Transaction(new puzzle_Client(), new puzzle_message_Request('GET', '/')));
     $p->onBefore($ev);
 }