Exemplo n.º 1
0
 public function testRedirectsWithGetOn303()
 {
     $h = new puzzle_subscriber_History();
     $mock = new puzzle_subscriber_Mock(array("HTTP/1.1 303 Moved Permanently\r\nLocation: /redirect\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();
     $client->getEmitter()->attach($mock);
     $client->getEmitter()->attach($h);
     $client->post('http://test.com/foo', array('body' => 'testing'));
     $requests = $h->getRequests();
     $this->assertEquals('POST', $requests[0]->getMethod());
     $this->assertEquals('GET', $requests[1]->getMethod());
 }
Exemplo n.º 2
0
 public function testCanForceMultipartUploadWithContentType()
 {
     $client = new puzzle_Client();
     $client->getEmitter()->attach(new puzzle_subscriber_Mock(array(new puzzle_message_Response(200))));
     $history = new puzzle_subscriber_History();
     $client->getEmitter()->attach($history);
     $client->post('http://foo.com', array('headers' => array('Content-Type' => 'multipart/form-data'), 'body' => array('foo' => 'bar')));
     $this->assertContains('multipart/form-data; boundary=', $history->getLastRequest()->getHeader('Content-Type'));
     $this->assertContains("Content-Disposition: form-data; name=\"foo\"\r\n\r\nbar", (string) $history->getLastRequest()->getBody());
 }