Completed
Pull Request — master (#13)
by Tom
03:57 queued 01:44
created

EntityIDTypeCompoundKeysTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testCompoundPrimaryKeysAreNotSupported() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLTests\Doctrine\Definition;
6
7
use Doctrine\Common\Annotations\AnnotationRegistry;
8
use GraphQL\Doctrine\Definition\EntityIDType;
9
use GraphQLTests\Doctrine\Blog\Model\UserPost;
10
use GraphQLTests\Doctrine\EntityManagerTrait;
11
12
final class EntityIDTypeCompoundKeysTest extends \PHPUnit\Framework\TestCase
13
{
14
    use EntityManagerTrait;
15
16
    /**
17
     * @var EntityIDType
18
     */
19
    private $type;
20
21
    public function setUp(): void
22
    {
23
        AnnotationRegistry::registerLoader('class_exists');
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\Common\Annotati...istry::registerLoader() has been deprecated: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists') ( Ignorable by Annotation )

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

23
        /** @scrutinizer ignore-deprecated */ AnnotationRegistry::registerLoader('class_exists');

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...
24
        $this->setUpEntityManager();
25
        $this->type = new EntityIDType($this->entityManager, UserPost::class, 'UserID');
26
    }
27
28
    public function testCompoundPrimaryKeysAreNotSupported(): void
29
    {
30
        $this->expectExceptionMessage(
31
            'Entities with compound primary keys are not supported by EntityIDType. '
32
            . 'The entity `'
33
            . 'GraphQLTests\Doctrine\Blog\Model\UserPost'
34
            . "` cannot serialize it's id."
35
        );
36
37
        $userPost = new UserPost(['user_id' => 1, 'post_id' => 2]);
38
        $actual = $this->type->serialize($userPost);
0 ignored issues
show
Unused Code introduced by
The assignment to $actual is dead and can be removed.
Loading history...
39
    }
40
}
41