diff --git a/tests/Unit/Config/RoutesFileTest.php b/tests/Unit/Config/RoutesFileTest.php new file mode 100644 index 00000000..a1cb3117 --- /dev/null +++ b/tests/Unit/Config/RoutesFileTest.php @@ -0,0 +1,43 @@ +getMockBuilder(RouteCollector::class) + ->disableOriginalConstructor() + ->onlyMethods(['addRoute']) + ->getMock(); + + $this->doesNotPerformAssertions(); + /** @see RouteCollector::addRoute */ + $route->expects($this->any()) + ->method('addRoute') + ->willReturnCallback(function ($httpMethod, $route, $handler) { + /** + * @param string|string[] $httpMethod + * @param string $route + * @param mixed $handler + */ + if (is_string($handler) || (is_array($handler) && is_string($handler[0]))) { + return; + } + + $this->fail( + sprintf('The route "%s %s" is not cacheable', implode(',', (array)$httpMethod), $route) + ); + }); + + require __DIR__ . '/../../../config/routes.php'; + } +}