RecordTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 11 1
A providerGetManagerName() 0 5 1
A testGetManagerName() 0 5 1
1
<?php
2
3
namespace Nip\Records\Tests;
4
5
use Mockery as m;
6
use Nip\Database\Connections\Connection;
7
use Nip\Records\Record;
8
use Nip\Records\RecordManager as Records;
9
use Nip\Records\Tests\AbstractTest;
10
11
/**
12
 * Class RecordTest
13
 * @package Nip\Records\Tests
14
 */
15
class RecordTest extends AbstractTest
16
{
17
18
    /**
19
     * @return array
20
     */
21
    public function providerGetManagerName()
22
    {
23
        return [
24
            ["Notifications_Table", "Notifications_Tables"],
25
            ["Donation", "Donations"],
26
        ];
27
    }
28
29
    /**
30
     * @dataProvider providerGetManagerName
31
     * @param string $recordName
32
     * @param string $managerName
33
     */
34
    public function testGetManagerName($recordName, $managerName)
35
    {
36
        $record = new Record();
37
        $record->setClassName($recordName);
0 ignored issues
show
Bug introduced by
$recordName of type string is incompatible with the type boolean|null expected by parameter $className of Nip\Records\AbstractModels\Record::setClassName(). ( Ignorable by Annotation )

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

37
        $record->setClassName(/** @scrutinizer ignore-type */ $recordName);
Loading history...
38
        self::assertSame($managerName, $record->getManagerName());
39
    }
40
41
    protected function setUp() : void
42
    {
43
        parent::setUp();
44
        $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

44
        $wrapper = new Connection(/** @scrutinizer ignore-type */ false);
Loading history...
45
46
        $manager = new Records();
47
        $manager->setDB($wrapper);
48
        $manager->setTable('pages');
49
50
        $this->object = new Record();
51
        $this->object->setManager($manager);
52
    }
53
}
54