Code Duplication    Length = 22-22 lines in 2 locations

spec/Client/ClientSpec.php 2 locations

@@ 49-70 (lines=22) @@
46
        $this->beConstructedWith($httpClient, 'abcd', self::BASE_URL, $messageFactory);
47
    }
48
49
    function it_should_send_get_request(
50
        HttpClient $httpClient,
51
        MessageFactory $messageFactory,
52
        RequestInterface $request,
53
        ResponseInterface $response,
54
        StreamInterface $stream
55
    ) {
56
        $headers     = ['Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Bearer efgh'];
57
        $rawQuery    = http_build_query(['query' => 'test']);
58
        $requestUri  = sprintf('%s/example?%s', self::BASE_URL, $rawQuery);
59
        $rawResponse = json_encode(['foo' => 'bar']);
60
61
        $messageFactory->createRequest('GET', $requestUri, $headers, null)->willReturn($request);
62
        $httpClient->sendRequest($request)->willReturn($response);
63
        $response->getStatusCode()->willReturn(200);
64
        $response->getBody()->willReturn($stream);
65
        $stream->__toString()->willReturn($rawResponse);
66
67
        $httpClient->sendRequest($request)->shouldBeCalled();
68
69
        $this->sendRequest('GET', 'example', ['query' => 'test']);
70
    }
71
72
    function it_should_send_post_request(
73
        HttpClient $httpClient,
@@ 72-93 (lines=22) @@
69
        $this->sendRequest('GET', 'example', ['query' => 'test']);
70
    }
71
72
    function it_should_send_post_request(
73
        HttpClient $httpClient,
74
        MessageFactory $messageFactory,
75
        RequestInterface $request,
76
        ResponseInterface $response,
77
        StreamInterface $stream
78
    ) {
79
        $headers     = ['Content-Type' => 'application/x-www-form-urlencoded', 'Authorization' => 'Bearer efgh'];
80
        $requestUri  = sprintf('%s/example', self::BASE_URL);
81
        $rawRequest  = http_build_query(['query' => 'test']);
82
        $rawResponse = json_encode(['foo' => 'bar']);
83
84
        $messageFactory->createRequest('POST', $requestUri, $headers, $rawRequest)->willReturn($request);
85
        $httpClient->sendRequest($request)->willReturn($response);
86
        $response->getStatusCode()->willReturn(200);
87
        $response->getBody()->willReturn($stream);
88
        $stream->__toString()->willReturn($rawResponse);
89
90
        $httpClient->sendRequest($request)->shouldBeCalled();
91
92
        $this->sendRequest('POST', 'example', ['query' => 'test']);
93
    }
94
95
    function it_should_ask_for_api_token_once(
96
        HttpClient $httpClient,