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

RecordTraitTest::testGetPrimaryKeyComposite()   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 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Records\Tests\Traits\HasPrimaryKey;
4
5
use Nip\Database\Connections\Connection;
6
use Nip\Records\Record;
7
use Nip\Records\RecordManager as Records;
8
use Nip\Records\Tests\AbstractTest;
9
10
/**
11
 * Class RecordTest
12
 * @package Nip\Records\Tests\Traits\HasPrimaryKey
13
 */
14
class RecordTraitTest extends AbstractTest
15
{
16
    public function testGetPrimaryKeySimple()
17
    {
18
        $this->object->getManager()->setPrimaryKey('id');
19
        $this->object->id = 99;
20
21
        static::assertEquals('99', $this->object->getPrimaryKey());
22
    }
23
24
    public function testGetPrimaryKeyComposite()
25
    {
26
        $this->object->getManager()->setPrimaryKey(['id_parent', 'type']);
27
        $this->object->id_parent = 99;
28
        $this->object->type = 'book';
29
30
        static::assertEquals(['id_parent' => 99, 'type' => 'book'], $this->object->getPrimaryKey());
31
    }
32
33
    protected function setUp()
34
    {
35
        parent::setUp();
36
        $wrapper = new Connection(false);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type Closure|PDO expected by parameter $pdo of Nip\Database\Connections\Connection::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
        $wrapper = new Connection(/** @scrutinizer ignore-type */ false);
Loading history...
37
38
        $manager = new Records();
39
        $manager->setDB($wrapper);
40
        $manager->setTable('pages');
41
42
        $this->object = new Record();
43
        $this->object->setManager($manager);
44
    }
45
}
46