ClientTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 2
eloc 16
c 2
b 2
f 0
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testInitIdentifierFromDB() 0 10 1
A testSetIdentifier() 0 14 1
1
<?php
2
3
namespace ByTIC\Hello\Tests\Models\Clients;
4
5
use ByTIC\Hello\Models\Clients\Client;
6
use ByTIC\Hello\Models\Clients\Clients;
7
use ByTIC\Hello\Tests\AbstractTest;
8
9
/**
10
 * Class ClientTest
11
 * @package ByTIC\Hello\Tests\Models\Clients
12
 */
13
class ClientTest extends AbstractTest
14
{
15
    public function testInitIdentifierFromDB()
16
    {
17
        $client = new Client();
18
        self::assertGreaterThan('10', strlen($client->getIdentifier()));
19
20
        $client->writeData(['id' => 9, 'identifier' => '']);
21
        self::assertEmpty($client->getIdentifier());
22
23
        $client->writeData(['id' => 9, 'identifier' => '9999']);
24
        self::assertSame('9999', $client->getIdentifier());
25
    }
26
27
    public function testSetIdentifier()
28
    {
29
        /** @var Clients $clients */
30
        $clients = \Mockery::mock(Clients::class)->makePartial();
31
        $clients->shouldReceive('getFields')->andReturn(['id', 'identifier', 'secret']);
0 ignored issues
show
Bug introduced by
The method andReturn() 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

31
        $clients->shouldReceive('getFields')->/** @scrutinizer ignore-call */ andReturn(['id', 'identifier', 'secret']);

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
The method shouldReceive() does not exist on ByTIC\Hello\Models\Clients\Clients. 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

31
        $clients->/** @scrutinizer ignore-call */ 
32
                  shouldReceive('getFields')->andReturn(['id', 'identifier', 'secret']);
Loading history...
Bug introduced by
The method andReturn() does not exist on ByTIC\Hello\Models\Clients\Clients. 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

31
        $clients->shouldReceive('getFields')->/** @scrutinizer ignore-call */ andReturn(['id', 'identifier', 'secret']);
Loading history...
32
        $clients->shouldReceive('getPrimaryKey')->andReturn('id');
33
        $clients->shouldReceive('getModel')->andReturn(Client::class);
34
35
        $client = $clients->getNew();
36
        $identifier = $client->getIdentifier();
37
        self::assertGreaterThan(30, strlen($identifier));
38
39
        $data = $clients->getQueryModelData($client);
40
        self::assertArrayHasKey('identifier', $data);
41
    }
42
}
43