Failed Conditions
Pull Request — master (#25)
by Chad
02:50
created

DataWrapperTest::basicUsage()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 36
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 30
nc 1
nop 0
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');
0 ignored issues
show
Unused Code introduced by
The call to DataWrapper::__construct() has too many arguments starting with 'characters'.

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.

Loading history...
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