1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Chadicus\Marvel\Api; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @coversDefaultClass \Chadicus\Marvel\Api\DataWrapper |
7
|
|
|
* @covers ::<protected> |
8
|
|
|
* @covers ::__construct |
9
|
|
|
*/ |
10
|
|
|
final class DataWrapperTest extends \PHPUnit_Framework_TestCase |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Verify basic behaviour of the DataWrapper class |
14
|
|
|
* |
15
|
|
|
* @test |
16
|
|
|
* @covers ::getCode |
17
|
|
|
* @covers ::getStatus |
18
|
|
|
* @covers ::getCopyright |
19
|
|
|
* @covers ::getAttributionText |
20
|
|
|
* @covers ::getAttributionHTML |
21
|
|
|
* @covers ::getETag |
22
|
|
|
* @covers ::getData |
23
|
|
|
* |
24
|
|
|
* @return void |
25
|
|
|
*/ |
26
|
|
|
public function basicUsage() |
27
|
|
|
{ |
28
|
|
|
$input = [ |
29
|
|
|
'code' => 1, |
30
|
|
|
'status' => 'a status', |
31
|
|
|
'copyright' => 'a copyright', |
32
|
|
|
'attributionText' => 'a attributionText', |
33
|
|
|
'attributionHTML' => 'a attributionHTML', |
34
|
|
|
'etag' => 'a etag', |
35
|
|
|
'data' => [ |
36
|
|
|
'offset' => 9, |
37
|
|
|
'limit' => 6, |
38
|
|
|
'total' => 3, |
39
|
|
|
'count' => 4, |
40
|
|
|
'results' => [['id' => 1, 'resourceURI' => Client::BASE_URL . 'characters/1']], |
41
|
|
|
], |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
$entityWrapper = new DataWrapper($input, 'characters'); |
|
|
|
|
45
|
|
|
$this->assertSame($input['code'], $entityWrapper->getCode()); |
46
|
|
|
$this->assertSame($input['status'], $entityWrapper->getStatus()); |
47
|
|
|
$this->assertSame($input['copyright'], $entityWrapper->getCopyright()); |
48
|
|
|
$this->assertSame($input['attributionText'], $entityWrapper->getAttributionText()); |
49
|
|
|
$this->assertSame($input['attributionHTML'], $entityWrapper->getAttributionHTML()); |
50
|
|
|
$this->assertSame($input['etag'], $entityWrapper->getETag()); |
51
|
|
|
|
52
|
|
|
$data = $entityWrapper->getData(); |
53
|
|
|
$this->assertSame($input['data']['offset'], $data->getOffset()); |
54
|
|
|
$this->assertSame($input['data']['limit'], $data->getLimit()); |
55
|
|
|
$this->assertSame($input['data']['total'], $data->getTotal()); |
56
|
|
|
$this->assertSame($input['data']['count'], $data->getCount()); |
57
|
|
|
$this->assertSame(1, count($data->getResults())); |
58
|
|
|
$characters = $data->getResults(); |
59
|
|
|
$this->assertInstanceOf('\Chadicus\Marvel\Api\Entities\Character', $characters[0]); |
60
|
|
|
$this->assertSame(1, $characters[0]->getId()); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.