| @@ 94-110 (lines=17) @@ | ||
| 91 | * @dataProvider jsonAcceptationProvider |
|
| 92 | * @param bool $isJsonAccepted |
|
| 93 | */ |
|
| 94 | public function testBuildRequest($isJsonAccepted) |
|
| 95 | { |
|
| 96 | $stub = $this->getStub(); |
|
| 97 | ||
| 98 | $client = new GuzzleHttpClient(); |
|
| 99 | $request = $client->createRequest('GET', 'http://www.example.org/'); |
|
| 100 | ||
| 101 | $this->invokeMethod($stub, 'buildRequest', [$request, $isJsonAccepted]); |
|
| 102 | ||
| 103 | if ($isJsonAccepted) { |
|
| 104 | $this->assertNotNull($request->getHeader('Accept')); |
|
| 105 | } else { |
|
| 106 | $this->assertEmpty($request->getHeader('Accept')); |
|
| 107 | } |
|
| 108 | $this->assertNotNull($request->getHeader('Accept-Charset')); |
|
| 109 | ||
| 110 | } |
|
| 111 | ||
| 112 | public function testApiGet() |
|
| 113 | { |
|
| @@ 112-126 (lines=15) @@ | ||
| 109 | ||
| 110 | } |
|
| 111 | ||
| 112 | public function testApiGet() |
|
| 113 | { |
|
| 114 | $validResponse = new Response(200); |
|
| 115 | ||
| 116 | $client = $this->getMock(GuzzleHttpClient::class, ['send']); |
|
| 117 | $client->expects($this->once()) |
|
| 118 | ->method('send') |
|
| 119 | ->willReturn($validResponse); |
|
| 120 | ||
| 121 | $stub = $this->getStub(); |
|
| 122 | $stub->setClient($client); |
|
| 123 | ||
| 124 | $response = $this->invokeMethod($stub, 'apiGet', ['']); |
|
| 125 | $this->assertEquals($validResponse, $response); |
|
| 126 | } |
|
| 127 | } |
|
| 128 | ||