Code Duplication    Length = 20-22 lines in 2 locations

spec/Client/GraphQLClientSpec.php 2 locations

@@ 54-75 (lines=22) @@
51
        $this->query('{ me { firstName } }');
52
    }
53
54
    public function it_should_not_send_auth_request_before_graphql_request_if_user_is_authenticated(
55
        HttpClient $httpClient,
56
        MessageFactory $messageFactory,
57
        RequestInterface $request,
58
        ResponseInterface $response,
59
        StreamInterface $stream,
60
        AuthClient $authClient
61
    ) {
62
        $messageFactory->createRequest('POST', self::GRAPHQL_ENDPOINT, Argument::type('array'), Argument::type(MultipartStream::class))->willReturn($request);
63
        $httpClient->sendRequest($request)->willReturn($response);
64
        $response->getStatusCode()->willReturn(200);
65
        $response->getBody()->willReturn($stream);
66
        $stream->__toString()->willReturn(json_encode([
67
            'me' => ['firstName' => 'Hugo'],
68
        ]));
69
70
        $authClient->getApiToken()->willReturn('<api token>')->shouldBeCalled();
71
        $authClient->isAuthenticated()->willReturn(true)->shouldBeCalled();
72
        $authClient->auth()->shouldNotBeCalled();
73
74
        $this->query('{ me { firstName } }');
75
    }
76
77
    public function it_should_send_graphql_query()
78
    {
@@ 136-155 (lines=20) @@
133
    {
134
    }
135
136
    public function it_should_handle_invalid_json(
137
        HttpClient $httpClient,
138
        MessageFactory $messageFactory,
139
        RequestInterface $request,
140
        ResponseInterface $response,
141
        StreamInterface $stream,
142
        AuthClient $authClient
143
    ) {
144
        $messageFactory->createRequest('POST', self::GRAPHQL_ENDPOINT, Argument::type('array'), Argument::type(MultipartStream::class))->willReturn($request);
145
        $httpClient->sendRequest($request)->willReturn($response);
146
        $response->getStatusCode()->willReturn(200);
147
        $response->getBody()->willReturn($stream);
148
        $stream->__toString()->willReturn('invalid JSON');
149
150
        $authClient->getApiToken()->willReturn('<api token>')->shouldBeCalled();
151
        $authClient->isAuthenticated()->willReturn(true)->shouldBeCalled();
152
        $authClient->auth()->shouldNotBeCalled();
153
154
        $this->shouldThrow(InvalidResponseException::class)->during('query', ['{ me { firstName } }']);
155
    }
156
}
157