Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Discovered a bug when using non-accept routes as well

  • Loading branch information...
commit 727241be8d08428fd05efcd052d9ef664690b2e0 1 parent a72e293
@jmather jmather authored
Showing with 23 additions and 1 deletion.
  1. +17 −0 Tests/SingleControllerRoutingTest.php
  2. +6 −1 UrlMatcher.php
View
17 Tests/SingleControllerRoutingTest.php
@@ -38,6 +38,10 @@ public function createApplication()
return new Response($cont, 200, array('Content-Type' => $accept_header));
})->accept(array('application/ven.test.v1+json', 'application/ven.test.v1+xml'));
+ $controllers1->get('/other-test', function() use ($app) {
+ return new Response('response', 200);
+ });
+
$app->mount('/', $controllers1);
@@ -74,6 +78,19 @@ public function testValidV1JSONCall()
$this->assertEquals('{"content":"hello"}', $result, 'response is correct');
}
+ public function testValidNonAcceptCall()
+ {
+ $client = $this->createClient();
+ $crawler = $client->request('GET', '/other-test');
+
+ $this->assertEquals(200, $client->getResponse()->getStatusCode());
+
+ $expected = 'response';
+ $actual = $client->getResponse()->getContent();
+
+ $this->assertEquals($expected, $actual, 'basic response is correct');
+ }
+
/**
* @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException
*/
View
7 UrlMatcher.php
@@ -36,6 +36,11 @@ protected function handleRouteRequirements($pathinfo, $name, BaseRoute $route)
}
}
- return array(self::REQUIREMENT_MISMATCH, null);
+ if ($route->getRequirement('_accept') != null)
+ {
+ return array(self::REQUIREMENT_MISMATCH, null);
+ }
+
+ return array(self::REQUIREMENT_MATCH, null);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.