Code Duplication    Length = 18-18 lines in 2 locations

tests/RateLimitMiddlewareTest.php 2 locations

@@ 25-42 (lines=18) @@
22
     *
23
     * @return void
24
     */
25
    public function invoke()
26
    {
27
        $middleware = $this->getMiddleware(
28
            $this->getClientExtractor($this->getLimitedClient(true)),
29
            $this->getResponseFactory(new Response('php://memory', 429))
30
        );
31
32
        $nextMiddleware = function ($request, $response) {
33
            return $response;
34
        };
35
36
        $response = new Response();
37
38
        $this->assertSame(
39
            $response,
40
            $middleware(new ServerRequest(), $response, $nextMiddleware)
41
        );
42
    }
43
44
    /**
45
     * @test
@@ 50-67 (lines=18) @@
47
     *
48
     * @return void
49
     */
50
    public function invokeLimitExceeded()
51
    {
52
        $limitResponse = new Response('php://memory', 429);
53
54
        $middleware = $this->getMiddleware(
55
            $this->getClientExtractor($this->getLimitedClient(false)),
56
            $this->getResponseFactory($limitResponse)
57
        );
58
59
        $nextMiddleware = function ($request, $response) {
60
            throw new \Exception('$next was call but should not have been.');
61
        };
62
63
        $this->assertSame(
64
            $limitResponse,
65
            $middleware(new ServerRequest(), new Response(), $nextMiddleware)
66
        );
67
    }
68
69
    private function getLimitedClient(bool $canMakeRequest) : LimitedClientInterface
70
    {