RecordTest::testNewRelation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 16
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Records\Tests\Traits\Relations;
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
use Nip\Records\Traits\Relations\HasRelationsRecordTrait;
11
12
/**
13
 * Class RecordTest
14
 * @package Nip\Records\Tests
15
 *
16
 * @property HasRelationsRecordTrait $object
17
 */
18
class RecordTest extends AbstractTest
19
{
20
    public function testNewRelation()
21
    {
22
        $users = m::namedMock('Users', Records::class)->shouldDeferMissing()
0 ignored issues
show
Deprecated Code introduced by
The function Mockery\LegacyMockInterface::shouldDeferMissing() has been deprecated: 2.0.0 Please use makePartial() instead ( Ignorable by Annotation )

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

22
        $users = /** @scrutinizer ignore-deprecated */ m::namedMock('Users', Records::class)->shouldDeferMissing()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
23
            ->shouldReceive('instance')->andReturnSelf()
24
            ->getMock();
25
26
        m::namedMock('User', Record::class);
27
28
        $manager = $this->object->getManager();
29
        $relation = $manager->belongsTo('User');
0 ignored issues
show
Bug introduced by
The method belongsTo() does not exist on Nip\Records\AbstractModels\RecordManager. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

29
        /** @scrutinizer ignore-call */ 
30
        $relation = $manager->belongsTo('User');
Loading history...
30
        $relation->setWith($users);
0 ignored issues
show
Bug introduced by
The method setWith() does not exist on Nip\Records\Collections\Collection. ( Ignorable by Annotation )

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

30
        $relation->/** @scrutinizer ignore-call */ 
31
                   setWith($users);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug introduced by
It seems like setWith() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

30
        $relation->/** @scrutinizer ignore-call */ 
31
                   setWith($users);
Loading history...
Bug introduced by
The method setWith() does not exist on Nip\Records\AbstractModels\RecordManager. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

30
        $relation->/** @scrutinizer ignore-call */ 
31
                   setWith($users);
Loading history...
31
32
        $relation = $this->object->newRelation('User');
33
34
        static::assertSame($this->object, $relation->getItem());
35
        static::assertSame($users, $relation->getWith());
36
    }
37
38
    protected function setUp(): void
39
    {
40
        parent::setUp();
41
        $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

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