summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-09-06 17:30:04 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2019-09-06 17:30:04 +0200
commit64c4743f57c2444a2e40ab4f115cbc6bdc9bcde1 (patch)
treef8607f41227c8bc75d2c2584452e3938a06d137a /tests
parenta02f5e61be0357bf56306a7177339ad4e9e3999a (diff)
Routes config: Added test to ensure that routes are cacheable in production
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Config/RoutesFileTest.php43
1 files changed, 43 insertions, 0 deletions
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 @@
+<?php
+
+namespace Engelsystem\Test\Unit\Config;
+
+use FastRoute\RouteCollector;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
+class RoutesFileTest extends TestCase
+{
+ /**
+ * @doesNotPerformAssertions
+ */
+ public function testLoadRoutes()
+ {
+ /** @var RouteCollector|MockObject $route */
+ $route = $this->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';
+ }
+}