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

CollectionTest::testGetRecordKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
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