function testAddsApplicationNameIfApplicationInternalHeaderIsSet()
 {
     $request = new Request();
     $request->setHeader('Asar-Internal-Application-Name', 'FooApp');
     $filtered_request = $this->filter->filterRequest($request);
     $this->assertEquals('FooApp', $this->debug->get('Application'));
 }
 /**
  * @dataProvider dataClientSendsRequest
  */
 function testClientSendsRequest($method, $options)
 {
     $request = new Request($options);
     $request->setMethod($method);
     $this->server->expects($this->once())->method('handleRequest')->with($request);
     call_user_func_array(array($this->client, $method), array($this->server, $options));
 }
 /**
  * @dataProvider dataArgsPasssingToNegotiator
  */
 function testArgsPasssingToNegotiator($resource_name, $request_options, $files, $available_types)
 {
     foreach ($files as $file) {
         $this->TFM->newFile($file, '');
     }
     $request = new Request($request_options);
     $this->content_negotiator->expects($this->once())->method('negotiateFormat')->with($request->getHeader('Accept'), $available_types);
     $this->RT->locateFor($resource_name, $request);
 }
 function testSettingApplicationNameInInternalHeader()
 {
     $request = new Request();
     $debug = new Debug();
     $filter = $this->getMock('Asar\\RequestFilter\\RequestFilterInterface');
     $request->setHeader('Asar-Internal-Debug', $debug);
     $filter->expects($this->once())->method('filterRequest')->with($request)->will($this->returnValue($request));
     $this->routerReturnsResource();
     $app = new Application('Some_Name', $this->router, $this->sm, $this->map, array($filter));
     $app->handleRequest($request);
     $this->assertEquals('Some_Name', $debug->get('Application'));
 }
 function testExportRequestWithParamsUrlEncodesParamValues()
 {
     $R = new Request(array('path' => '/handler', 'params' => array('foo' => 'bar', 'goo[]' => 'jazz', 'good' => 'bad=')));
     $expected = 'foo=bar&' . urlencode('goo[]') . '=jazz&good=bad' . urlencode('=');
     $str = $R->export();
     $this->assertStringStartsWith("GET /handler?{$expected} HTTP/1.1\r\n", $str, $str);
 }
 function testResourceWithoutDefinedHttpMethodShouldReturn405HttpStatus()
 {
     $R = $this->getMock('Asar\\Resource', array('some_method'));
     $request = new Request();
     foreach (array('GET', 'POST', 'PUT', 'DELETE') as $method) {
         $request->setMethod($method);
         $response = $R->handleRequest($request);
         $this->assertEquals(405, $response->getStatus());
     }
 }
Beispiel #7
0
 private function sendRequestByMethod($server, $options, $method)
 {
     $request = new Request($options);
     $request->setMethod($method);
     return $this->sendRequest($server, $request);
 }