summaryrefslogtreecommitdiff
path: root/tests/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Utils')
-rw-r--r--tests/Utils/TestCallable.php2
-rw-r--r--tests/Utils/TestMiddleware.php27
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/Utils/TestCallable.php b/tests/Utils/TestCallable.php
index 526ddf4..67b3d6c 100644
--- a/tests/Utils/TestCallable.php
+++ b/tests/Utils/TestCallable.php
@@ -51,7 +51,7 @@ class TestCallable
return $this->calls[$this->getCallCount() - 1] ?? null;
}
- public function assertIsCalled(): void
+ public function assertCalled(): void
{
Assert::assertGreaterThan(0, $this->getCallCount(), 'Not been called');
}
diff --git a/tests/Utils/TestMiddleware.php b/tests/Utils/TestMiddleware.php
new file mode 100644
index 0000000..2f3ed32
--- /dev/null
+++ b/tests/Utils/TestMiddleware.php
@@ -0,0 +1,27 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Lightscale\Router\Test\Utils;
+
+use Lightscale\Router\Contracts\Middleware;
+use PHPUnit\Framework\Assert;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+
+class TestMiddleware implements Middleware
+{
+ private int $calls = 0;
+
+ public function handle(ServerRequestInterface $request, callable $next): ResponseInterface
+ {
+ ++$this->calls;
+
+ return $next($request);
+ }
+
+ public function assertCalled(): void
+ {
+ Assert::assertGreaterThan(0, $this->calls);
+ }
+}