1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @mixin PHPUnit_Framework_TestCase |
5
|
|
|
*/ |
6
|
|
|
class RatingApiControllerTest extends FunctionalTest |
7
|
|
|
{ |
8
|
|
|
protected static $fixture_file = 'RatingApiControllerTest.yml'; |
9
|
|
|
|
10
|
|
|
public function testErrorWhenMissingParams() |
11
|
|
|
{ |
12
|
|
|
$response = $this->get('api/rating'); |
13
|
|
|
|
14
|
|
|
$this->assertJson($response->getBody()); |
|
|
|
|
15
|
|
|
|
16
|
|
|
$result = json_decode($response->getBody()); |
17
|
|
|
$this->assertFalse($result->success); |
|
|
|
|
18
|
|
|
$this->assertContains('Missing', $result->message); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testErrorWhenModuleNotFound() |
22
|
|
|
{ |
23
|
|
|
$response = $this->get('api/rating/bar/baz'); |
24
|
|
|
|
25
|
|
|
$this->assertJson($response->getBody()); |
|
|
|
|
26
|
|
|
|
27
|
|
|
$result = json_decode($response->getBody()); |
28
|
|
|
$this->assertFalse($result->success); |
|
|
|
|
29
|
|
|
$this->assertContains('not be found', $result->message); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.