Failed Conditions
Pull Request — master (#11)
by Adrien
15:48 queued 12:33
created

ModelResourceTest::testConstructorVariants()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcodevTests\Felix\Acl;
6
7
use Ecodev\Felix\Acl\ModelResource;
1 ignored issue
show
Bug introduced by
The type Ecodev\Felix\Acl\ModelResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use EcodevTests\Felix\Blog\Model\User;
9
use InvalidArgumentException;
10
use PHPUnit\Framework\TestCase;
11
12
final class ModelResourceTest extends TestCase
13
{
14
    public function testConstructorVariants(): void
15
    {
16
        // Constructor with pre-loaded model
17
        $user = new User();
18
        $resource = new ModelResource(User::class, $user);
19
        self::assertSame($user, $resource->getInstance(), 'should be able to get back model');
20
        self::assertSame('User#null', $resource->getName(), 'should have unique name');
21
22
        $resourceWithoutInstance = new ModelResource(User::class);
23
        self::assertSame('User#null', $resourceWithoutInstance->getName(), 'should have name even without instance');
24
    }
25
26
    public function testUnknownClassMustThrow(): void
27
    {
28
        $this->expectException(InvalidArgumentException::class);
29
30
        new ModelResource('non-existing-class-name');
31
    }
32
}
33