Code Duplication    Length = 20-20 lines in 2 locations

spec/Client/AuthClientSpec.php 2 locations

@@ 45-64 (lines=20) @@
42
        $this->isAuthenticated()->shouldReturn(true);
43
    }
44
45
    public function it_should_throw_authentication_exception_if_api_key_is_invalid(
46
        HttpClient $httpClient,
47
        MessageFactory $messageFactory,
48
        RequestInterface $tokenRequest,
49
        ResponseInterface $tokenResponse,
50
        StreamInterface $tokenStream
51
    ) {
52
        $headers = ['Content-Type' => 'application/x-www-form-urlencoded'];
53
        $body    = http_build_query(['api_key' => '<api key>']);
54
55
        $messageFactory->createRequest('POST', self::LOGIN_ENDPOINT, $headers, $body)->willReturn($tokenRequest);
56
        $httpClient->sendRequest($tokenRequest)->willReturn($tokenResponse);
57
        $tokenResponse->getStatusCode()->willReturn(401);
58
        $tokenResponse->getBody()->willReturn($tokenStream);
59
        $tokenStream->__toString()->willReturn('{"message": "Invalid Credentials", "code": 401}');
60
61
        $this->shouldThrow(AuthenticationException::class)->during('auth');
62
        $this->getApiToken()->shouldBeNull();
63
        $this->isAuthenticated()->shouldReturn(false);
64
    }
65
66
    public function it_should_throw_invalid_response_exception_if_invalid_json(
67
        HttpClient $httpClient,
@@ 66-85 (lines=20) @@
63
        $this->isAuthenticated()->shouldReturn(false);
64
    }
65
66
    public function it_should_throw_invalid_response_exception_if_invalid_json(
67
        HttpClient $httpClient,
68
        MessageFactory $messageFactory,
69
        RequestInterface $tokenRequest,
70
        ResponseInterface $tokenResponse,
71
        StreamInterface $tokenStream
72
    ) {
73
        $headers = ['Content-Type' => 'application/x-www-form-urlencoded'];
74
        $body    = http_build_query(['api_key' => '<api key>']);
75
76
        $messageFactory->createRequest('POST', self::LOGIN_ENDPOINT, $headers, $body)->willReturn($tokenRequest);
77
        $httpClient->sendRequest($tokenRequest)->willReturn($tokenResponse);
78
        $tokenResponse->getStatusCode()->willReturn(200);
79
        $tokenResponse->getBody()->willReturn($tokenStream);
80
        $tokenStream->__toString()->willReturn('{"invalid JSON",}');
81
82
        $this->shouldThrow(InvalidResponseException::class)->during('auth');
83
        $this->getApiToken()->shouldBeNull();
84
        $this->isAuthenticated()->shouldReturn(false);
85
    }
86
}
87