mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-23 06:02:57 +02:00
Fixed broken tests
This commit is contained in:
@@ -25,12 +25,14 @@ class MiddlewareManagerTest extends TestCase
|
||||
#[Test]
|
||||
public function it_registers_application_middlewares(): void
|
||||
{
|
||||
$arguments = array_map(static function (string $middleware): array {
|
||||
return [$middleware];
|
||||
}, self::MIDDLEWARES);
|
||||
|
||||
$app = $this->createMock(App::class);
|
||||
$app->expects($this->atLeast(1))->method('add')->withConsecutive(...$arguments);
|
||||
$app->expects($matcher = $this->atLeast(1))->method('add')->willReturnCallback(
|
||||
function ($parameter) use ($matcher, $app): App {
|
||||
$this->assertSame(self::MIDDLEWARES[$matcher->numberOfInvocations() - 1], $parameter);
|
||||
|
||||
return $app;
|
||||
}
|
||||
);
|
||||
|
||||
(new MiddlewareManager($app, $this->config))();
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ use PHPUnit\Framework\Attributes\Test;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Tests\TestCase;
|
||||
use Whoops\Handler\Handler;
|
||||
use Whoops\Handler\JsonResponseHandler;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\RunInterface;
|
||||
@@ -57,9 +58,11 @@ class WhoopsMiddlewareTest extends TestCase
|
||||
$jsonHandler = new JsonResponseHandler;
|
||||
|
||||
$whoops = $this->createMock(RunInterface::class);
|
||||
$whoops->expects($this->exactly(2))->method('pushHandler')->withConsecutive(
|
||||
[$pageHandler],
|
||||
[$jsonHandler]
|
||||
$whoops->expects($matcher = $this->exactly(2))->method('pushHandler')->willReturnCallback(
|
||||
fn (Handler $parameter) => match ($matcher->numberOfInvocations()) {
|
||||
1 => $this->assertSame($pageHandler, $parameter),
|
||||
2 => $this->assertSame($jsonHandler, $parameter),
|
||||
}
|
||||
);
|
||||
|
||||
$middleware = new WhoopsMiddleware($whoops, $pageHandler, $jsonHandler);
|
||||
|
Reference in New Issue
Block a user