コード例 #1
0
ファイル: RequestTest.php プロジェクト: roydejong/Enlighten
 public function testRequestMethodPut()
 {
     $request = new Request();
     $request->setMethod(RequestMethod::PUT);
     $this->assertTrue($request->isPut());
     $this->assertFalse($request->isPost());
 }
コード例 #2
0
ファイル: RouteTest.php プロジェクト: roydejong/Enlighten
 public function testRegexPattern()
 {
     $route = new Route('/dir/(sample|example)(/?)', function () {
         // ...
     });
     $request = new Request();
     $request->setRequestUri('/dir/example/');
     $request->setMethod(RequestMethod::GET);
     $this->assertTrue($route->matches($request));
     $request = new Request();
     $request->setRequestUri('/dir/example');
     $request->setMethod(RequestMethod::GET);
     $this->assertTrue($route->matches($request));
     $request = new Request();
     $request->setRequestUri('/dir/sample/');
     $request->setMethod(RequestMethod::GET);
     $this->assertTrue($route->matches($request));
     $request = new Request();
     $request->setRequestUri('/dir/sample');
     $request->setMethod(RequestMethod::GET);
     $this->assertTrue($route->matches($request));
     $request = new Request();
     $request->setRequestUri('/dir/samples');
     $request->setMethod(RequestMethod::GET);
     $this->assertFalse($route->matches($request));
 }
コード例 #3
0
ファイル: EnlightenTest.php プロジェクト: roydejong/Enlighten
 /**
  * @runInSeparateProcess
  */
 public function testNotAllowedResponse()
 {
     $app = new Enlighten();
     $app->get('/sample', function () {
         echo 'hi!!!';
     });
     $optionsRequest = new Request();
     $optionsRequest->setRequestUri('/sample');
     $optionsRequest->setMethod(RequestMethod::POST);
     $app->setRequest($optionsRequest);
     $response = $app->start();
     $this->assertEquals(ResponseCode::HTTP_METHOD_NOT_ALLOWED, $response->getResponseCode());
 }