2019-09-06 17:30:04 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Config;
|
|
|
|
|
|
|
|
use FastRoute\RouteCollector;
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class RoutesFileTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @doesNotPerformAssertions
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testLoadRoutes(): void
|
2019-09-06 17:30:04 +02:00
|
|
|
{
|
|
|
|
/** @var RouteCollector|MockObject $route */
|
|
|
|
$route = $this->getMockBuilder(RouteCollector::class)
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->onlyMethods(['addRoute'])
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
$this->doesNotPerformAssertions();
|
|
|
|
/** @see RouteCollector::addRoute */
|
|
|
|
$route->expects($this->any())
|
|
|
|
->method('addRoute')
|
2022-12-14 19:15:20 +01:00
|
|
|
->willReturnCallback(function ($httpMethod, $route, $handler): void {
|
2019-09-06 17:30:04 +02:00
|
|
|
/**
|
|
|
|
* @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';
|
|
|
|
}
|
|
|
|
}
|