| @@ 32-41 (lines=10) @@ | ||
| 29 | $this->assertContains('not be found', $result->message); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function testResponseIncludesRating() |
|
| 33 | { |
|
| 34 | $response = $this->get('api/rating/foo/bar'); |
|
| 35 | ||
| 36 | $this->assertJson($response->getBody()); |
|
| 37 | ||
| 38 | $result = json_decode($response->getBody()); |
|
| 39 | $this->assertTrue($result->success); |
|
| 40 | $this->assertSame(53, $result->rating); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function testDetailedResponse() |
|
| 44 | { |
|
| @@ 43-52 (lines=10) @@ | ||
| 40 | $this->assertSame(53, $result->rating); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function testDetailedResponse() |
|
| 44 | { |
|
| 45 | $response = $this->get('api/rating/foo/bar?detailed'); |
|
| 46 | ||
| 47 | $this->assertJson($response->getBody()); |
|
| 48 | ||
| 49 | $result = json_decode($response->getBody()); |
|
| 50 | $this->assertTrue($result->success); |
|
| 51 | $this->assertSame(3, $result->metrics->coverage); |
|
| 52 | } |
|
| 53 | } |
|
| 54 | ||
| @@ 23-32 (lines=10) @@ | ||
| 20 | $this->assertEquals(83, $result->ratings->{'far/baz'}); |
|
| 21 | } |
|
| 22 | ||
| 23 | public function testMissingAddonsAreOmittedFromResults() |
|
| 24 | { |
|
| 25 | $response = $this->get('api/ratings?addons=silverstripe/imaginarymodule'); |
|
| 26 | ||
| 27 | $this->assertJson($response->getBody()); |
|
| 28 | ||
| 29 | $result = json_decode($response->getBody()); |
|
| 30 | $this->assertTrue($result->success); |
|
| 31 | $this->assertEmpty($result->ratings); |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| @@ 10-20 (lines=11) @@ | ||
| 7 | { |
|
| 8 | protected static $fixture_file = 'SupportedAddonsApiControllerTest.yml'; |
|
| 9 | ||
| 10 | public function testOnlySupportedAddonsAreReturned() |
|
| 11 | { |
|
| 12 | $response = $this->get('api/supported-addons'); |
|
| 13 | ||
| 14 | $this->assertJson($response->getBody()); |
|
| 15 | ||
| 16 | $result = json_decode($response->getBody()); |
|
| 17 | $this->assertTrue($result->success); |
|
| 18 | $this->assertContains('foo/supported-bar', $result->addons); |
|
| 19 | $this->assertNotContains('foo/unsupported-bar', $result->addons); |
|
| 20 | } |
|
| 21 | } |
|
| 22 | ||