/**
  * @test
  */
 public function noMatchingMethodWillReturnMethodNotAllowedFailureAndFirstCandidate()
 {
     $this->request = new ServerRequest([], [], '/users', 'HEAD');
     $route = RouteBuilder::route()->get('/users')->to('my.GetActionToken')->build();
     $this->router->setRoutes([$route, RouteBuilder::route()->post('/users')->to('my.PostActionToken')->build()]);
     $result = $this->router->match($this->request);
     $this->assertTrue($result->failed());
     $this->assertEquals(RoutingResult::FAILED_METHOD_NOT_ALLOWED, $result->getFailure());
     $this->assertSame($route, $result->getRoute());
 }
 /**
  * @see PHPUnit_Framework_TestCase::setUp()
  */
 protected function setUp()
 {
     parent::setUp();
     $matcherMockBuilder = $this->getMockBuilder(Matcher::class)->setMethods(['match']);
     $notMatchingMatcher = $matcherMockBuilder->getMock();
     $notMatchingMatcher->expects($this->any())->method('match')->will($this->returnValue(false));
     $matchingMatcher = $matcherMockBuilder->getMock();
     $matchingMatcher->expects($this->any())->method('match')->will($this->returnValue(true));
     $this->request = new ServerRequest();
     $this->router = new Psr7Router('http://localhost');
     $this->router->setRoutes([Route::get('/users')->to('my.GetActionToken'), Route::post('/users')->to('my.PostActionToken'), Route::get('/user/[:userId]')->to('my.GetActionTokenWithParam'), Route::get('/companies')->to('my.OtherGetActionToken'), Route::get('/offer/[:offerId]')->to('my.GetActionTokenWithMatchedParam')->ifMatches('offerId', $matchingMatcher), Route::get('/company/[:companyId]')->to('my.GetActionTokenWithUnmatchedParam')->ifMatches('companyId', $notMatchingMatcher)]);
 }