예제 #1
0
 public function testDispatchPutRequest()
 {
     $entityBodyFactory = new Bringit_EntityBodyFactory();
     $body = $entityBodyFactory->createFromString('test content');
     $header = new Bringit_Header_RequestHeader();
     $builder = new Bringit_RequestBuilder();
     $request = $builder->method(Bringit_Request::METHOD_PUT)->url('http://' . self::TESTHOST . '/test')->header($header)->body($body)->create();
     $dispatcher = new Bringit_RequestDispatcher();
     $response = $dispatcher->dispatch($request);
     $responseBody = $response->entityBody()->contentString();
     $this->assertWantedPattern('#The requested method PUT is not allowed#', $responseBody);
 }
 public function testDispatchPutRequest()
 {
     $entityBodyFactory = new Bringit_EntityBodyFactory();
     $body = $entityBodyFactory->createFromString('test content');
     $header = new Bringit_Header_RequestHeader();
     $builder = new Bringit_RequestBuilder();
     $request = $builder->method(Bringit_Request::METHOD_PUT)->url('http://' . self::TESTHOST . '/test')->header($header)->body($body)->create();
     $dispatcher = new Bringit_RequestDispatcher();
     $response = $dispatcher->dispatch($request);
     $responseBody = $response->entityBody()->contentString();
     $host = self::TESTHOST;
     $this->assertEqual("PUT /test HTTP/1.1\r\n" . "Host: {$host}\r\n" . "Content-Length: 12\r\n" . "\r\n" . "test content", $responseBody);
 }
예제 #3
0
 public function testPutRequest()
 {
     $builder = new Bringit_RequestBuilder();
     $url = new Bringit_Url('http://example.org:81/blarg');
     $header = new Bringit_Header_RequestHeader();
     $header['Content-Type'] = 'text/plain';
     $entityBodyFactory = new Bringit_EntityBodyFactory();
     $entityBody = $entityBodyFactory->createFromString('testing');
     $request = $builder->method(Bringit_Request::METHOD_PUT)->url($url)->header($header)->body($entityBody)->create();
     $this->assertIsA($request, 'Bringit_Request');
     $this->assertEqual($request->requestMethod(), Bringit_Request::METHOD_PUT);
     $this->assertReference($request->url(), $url);
     $this->assertReference($request->header(), $header);
     $this->assertTrue($request->hasEntityBody(), 'should have entity body');
     $this->assertReference($request->entityBody(), $entityBody);
     $this->assertEqual($request->requestLine()->__toString(), "PUT /blarg HTTP/1.1\r\n");
     $this->assertEqual($header['Host'], 'example.org:81');
 }