testCreateHydraPaginatedCollection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 18
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 22
rs 9.6666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Mapado\RestClientSdk\Tests\Units\Collection;
6
7
use atoum;
8
9
/**
10
 * HydraPaginatedCollection
11
 *
12
 * @uses   \atoum
13
 *
14
 * @author Florent Clerc <[email protected]>
15
 */
16
class HydraPaginatedCollection extends atoum
17
{
18
    /**
19
     * testCreateHydraPaginatedCollection
20
     */
21
    public function testCreateHydraPaginatedCollection()
22
    {
23
        $json = json_decode(file_get_contents(__DIR__ . '/../../data/ticketing.list.paginated.json'), true);
24
25
        $this
26
            ->given($collection = new \Mapado\RestClientSdk\Collection\HydraPaginatedCollection($json['hydra:member'], $json))
27
28
            ->then
29
            ->object($collection)
30
            ->isInstanceOf('Mapado\RestClientSdk\Collection\HydraPaginatedCollection')
31
            ->isInstanceOf('\Traversable')
32
            ->hasSize(2)
33
            ->and
34
            ->integer($collection->getTotalItems())->isEqualTo(6)
35
            ->and
36
            ->array($collection->toArray())->isEqualTo($json['hydra:member'])
37
            ->and
38
            ->variable($collection->getFirstPage())->isEqualTo($json['hydra:firstPage'])
39
            ->and
40
            ->variable($collection->getLastPage())->isEqualTo($json['hydra:lastPage'])
41
            ->and
42
            ->variable($collection->getNextPage())->isEqualTo($json['hydra:nextPage']);
43
    }
44
}
45