| Conditions | 2 |
| Paths | 2 |
| Total Lines | 40 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | public function testHandleMailChimpResponse() |
||
| 15 | { |
||
| 16 | $chimpifyRequestHandler = new ChimpifyRequestHandler(null, null, null, null, null); |
||
| 17 | |||
| 18 | $mailChimp = $this->getNewMailChimpMock(); |
||
| 19 | $mailChimp |
||
| 20 | ->shouldReceive('getLastResponse') |
||
| 21 | ->withNoArgs() |
||
| 22 | ->once(); |
||
| 23 | $mailChimp |
||
| 24 | ->shouldReceive('success') |
||
| 25 | ->withNoArgs() |
||
| 26 | ->once(); |
||
| 27 | |||
| 28 | try { |
||
| 29 | $chimpifyRequestHandler->handleMailChimpResponse($mailChimp); |
||
| 30 | } catch (Exception $e) { |
||
| 31 | $this->assertEquals('Error connecting to MailChimp API', $e->getMessage()); |
||
| 32 | } |
||
| 33 | |||
| 34 | $mailChimp = $this->getNewMailChimpMock(); |
||
| 35 | $mailChimp |
||
| 36 | ->shouldReceive('getLastResponse') |
||
| 37 | ->withNoArgs() |
||
| 38 | ->once() |
||
| 39 | ->andReturn([ |
||
| 40 | 'body' => json_encode(['items' => [['id' => 1]]]), |
||
| 41 | ]); |
||
| 42 | $mailChimp |
||
| 43 | ->shouldReceive('success') |
||
| 44 | ->withNoArgs() |
||
| 45 | ->once() |
||
| 46 | ->andReturn(true); |
||
| 47 | |||
| 48 | $result = $chimpifyRequestHandler->handleMailChimpResponse($mailChimp); |
||
| 49 | |||
| 50 | $this->assertEquals(true, is_array($result)); |
||
| 51 | $this->assertEquals(1, count($result['items'])); |
||
| 52 | $this->assertEquals(1, $result['items'][0]['id']); |
||
| 53 | } |
||
| 54 | |||
| 63 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.