Code Duplication    Length = 13-13 lines in 2 locations

module/Rest/test/Action/ShortCode/CreateShortCodeActionTest.php 2 locations

@@ 67-79 (lines=13) @@
64
    /**
65
     * @test
66
     */
67
    public function anInvalidUrlReturnsError()
68
    {
69
        $this->urlShortener->urlToShortCode(Argument::type(Uri::class), Argument::type('array'), Argument::cetera())
70
            ->willThrow(InvalidUrlException::class)
71
            ->shouldBeCalledTimes(1);
72
73
        $request = ServerRequestFactory::fromGlobals()->withParsedBody([
74
            'longUrl' => 'http://www.domain.com/foo/bar',
75
        ]);
76
        $response = $this->action->handle($request);
77
        $this->assertEquals(400, $response->getStatusCode());
78
        $this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::INVALID_URL_ERROR) > 0);
79
    }
80
81
    /**
82
     * @test
@@ 107-119 (lines=13) @@
104
    /**
105
     * @test
106
     */
107
    public function aGenericExceptionWillReturnError()
108
    {
109
        $this->urlShortener->urlToShortCode(Argument::type(Uri::class), Argument::type('array'), Argument::cetera())
110
            ->willThrow(\Exception::class)
111
            ->shouldBeCalledTimes(1);
112
113
        $request = ServerRequestFactory::fromGlobals()->withParsedBody([
114
            'longUrl' => 'http://www.domain.com/foo/bar',
115
        ]);
116
        $response = $this->action->handle($request);
117
        $this->assertEquals(500, $response->getStatusCode());
118
        $this->assertTrue(strpos($response->getBody()->getContents(), RestUtils::UNKNOWN_ERROR) > 0);
119
    }
120
}
121