Completed
Push — master ( 4ac004...470d43 )
by Gabriel
06:41
created

RecordsTraitTest::getManagerWithUnique()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Nip\Records\Tests\Traits\Unique;
4
5
use Nip\Records\Tests\AbstractTest;
6
use Nip\Records\Tests\Fixtures\Records\Books\Book;
7
use Nip\Records\Tests\Fixtures\Records\Books\Books;
8
9
/**
10
 * Class RecordsTraitTest
11
 * @package Nip\Records\Tests\Traits\Unique
12
 */
13
class RecordsTraitTest extends AbstractTest
14
{
15
    public function testGenerateExistsParams()
16
    {
17
        $manager = $this->getManagerWithUnique();
18
        $item = new Book();
19
20
        $params = $manager->generateExistsParams($item);
21
        self::assertSame(
22
            [
23
                'where' => [
24
                    'id_event_id_volunteer-UNQ' => "`id_event` = '' AND `id_volunteer` = ''",
25
                    'hash-UNQ' => "`hash` = ''"
26
                ],
27
            ],
28
            $params
29
        );
30
    }
31
32
    public function testGetUniqueFields()
33
    {
34
        $manager = $this->getManagerWithUnique();
35
36
        $unique = $manager->getUniqueFields();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $unique is correct as $manager->getUniqueFields() (which targets Nip\Records\Traits\Uniqu...rait::getUniqueFields()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
37
        self::assertSame(
38
            [
39
                'id_event_id_volunteer' => [
40
                    0 => 'id_event',
41
                    1 => 'id_volunteer'
42
                ],
43
                'hash' => [
44
                    0 => 'hash'
45
                ]
46
            ],
47
            $unique
48
        );
49
    }
50
51
    /**
52
     * @return Books
53
     */
54
    protected function getManagerWithUnique()
55
    {
56
        $manager = new Books();
57
        $structure = require TEST_FIXTURE_PATH
58
            . DIRECTORY_SEPARATOR . 'database_structure' . DIRECTORY_SEPARATOR . 'table_with_unique.php';
59
        $manager->setTableStructure($structure);
60
        return $manager;
61
    }
62
}
63