summaryrefslogtreecommitdiff
path: root/tests/Utils/TestMiddleware.php
blob: 2f3ed3235477ed0211e986380253530a9567a02a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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);
    }
}