Code Duplication    Length = 14-16 lines in 3 locations

module/Core/test/Action/QrCodeActionTest.php 3 locations

@@ 40-53 (lines=14) @@
37
    /**
38
     * @test
39
     */
40
    public function aNonexistentShortCodeWillReturnNotFoundResponse()
41
    {
42
        $shortCode = 'abc123';
43
        $this->urlShortener->shortCodeToUrl($shortCode)->willReturn(null)->shouldBeCalledTimes(1);
44
45
        $resp = $this->action->__invoke(
46
            ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode),
47
            new Response(),
48
            function ($req, $resp) {
49
                return $resp;
50
            }
51
        );
52
        $this->assertEquals(404, $resp->getStatusCode());
53
    }
54
55
    /**
56
     * @test
@@ 58-72 (lines=15) @@
55
    /**
56
     * @test
57
     */
58
    public function anInvalidShortCodeWillReturnNotFoundResponse()
59
    {
60
        $shortCode = 'abc123';
61
        $this->urlShortener->shortCodeToUrl($shortCode)->willThrow(InvalidShortCodeException::class)
62
                                                       ->shouldBeCalledTimes(1);
63
64
        $resp = $this->action->__invoke(
65
            ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode),
66
            new Response(),
67
            function ($req, $resp) {
68
                return $resp;
69
            }
70
        );
71
        $this->assertEquals(404, $resp->getStatusCode());
72
    }
73
74
    /**
75
     * @test
@@ 77-92 (lines=16) @@
74
    /**
75
     * @test
76
     */
77
    public function aCorrectRequestReturnsTheQrCodeResponse()
78
    {
79
        $shortCode = 'abc123';
80
        $this->urlShortener->shortCodeToUrl($shortCode)->willReturn(new ShortUrl())->shouldBeCalledTimes(1);
81
82
        $resp = $this->action->__invoke(
83
            ServerRequestFactory::fromGlobals()->withAttribute('shortCode', $shortCode),
84
            new Response(),
85
            function ($req, $resp) {
86
                return $resp;
87
            }
88
        );
89
90
        $this->assertInstanceOf(QrCodeResponse::class, $resp);
91
        $this->assertEquals(200, $resp->getStatusCode());
92
    }
93
}
94