Completed
Push — master ( 09bb07...3577e6 )
by Gabriel
04:08 queued 10s
created

CollectionTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetRecordKey() 0 7 1
A getRecordKeyData() 0 6 1
1
<?php
2
3
namespace Nip\Records\Tests\Collections;
4
5
use Nip\Records\Collections\Collection;
6
use Nip\Records\Record;
7
use Nip\Records\Tests\AbstractTest;
8
use Nip\Records\Tests\Fixtures\Records\Books\Books;
9
10
/**
11
 * Class CollectionTest
12
 * @package Nip\Records\Tests\Collections
13
 */
14
class CollectionTest extends AbstractTest
15
{
16
17
    /**
18
     * @param $expected
19
     * @param $index
20
     * @param $data
21
     * @dataProvider getRecordKeyData
22
     */
23
    public function testGetRecordKey($expected, $index, $data)
24
    {
25
        $collection = new Collection();
26
        $record = Books::instance()->getNew();
27
        $record->writeData($data);
28
29
        self::assertEquals($expected, $collection->getRecordKey($record, $index));
30
    }
31
32
    /**
33
     * @return array
34
     */
35
    public static function getRecordKeyData()
36
    {
37
        return [
38
            ['9', null, ['id' => 9]],
39
            ['9', 'id', ['id' => 9]],
40
            ['9-test', ['id', 'name'], ['id' => 9, 'name' => 'test']],
41
        ];
42
    }
43
}
44