| @@ 31-44 (lines=14) @@ | ||
| 28 | $loader->getAddonNames(); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function testNonJsonResponsesAreHandled() |
|
| 32 | { |
|
| 33 | $loader = new SupportedAddonsLoader(); |
|
| 34 | $loader->setGuzzleClient($this->getMockClient(new Response( |
|
| 35 | 200, |
|
| 36 | ['Content-Type' => 'text/html; charset=utf-8'] |
|
| 37 | ))); |
|
| 38 | ||
| 39 | $this->setExpectedException( |
|
| 40 | RuntimeException::class, |
|
| 41 | 'Could not obtain information about supported addons. Response is not JSON' |
|
| 42 | ); |
|
| 43 | $loader->getAddonNames(); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function testUnsuccessfulResponsesAreHandled() |
|
| 47 | { |
|
| @@ 46-60 (lines=15) @@ | ||
| 43 | $loader->getAddonNames(); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function testUnsuccessfulResponsesAreHandled() |
|
| 47 | { |
|
| 48 | $loader = new SupportedAddonsLoader(); |
|
| 49 | $loader->setGuzzleClient($this->getMockClient(new Response( |
|
| 50 | 200, |
|
| 51 | ['Content-Type' => 'application/json'], |
|
| 52 | json_encode(['success' => 'false']) |
|
| 53 | ))); |
|
| 54 | ||
| 55 | $this->setExpectedException( |
|
| 56 | RuntimeException::class, |
|
| 57 | 'Could not obtain information about supported addons. Response returned unsuccessfully' |
|
| 58 | ); |
|
| 59 | $loader->getAddonNames(); |
|
| 60 | } |
|
| 61 | ||
| 62 | ||
| 63 | public function testAddonsAreParsedAndReturnedCorrectly() |
|