Completed
Push — master ( ba8ed9...770316 )
by Jeroen
06:11
created

MappingListenerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testListener() 0 13 1
1
<?php
2
3
namespace Kunstmaan\AdminBundle\Tests\EventListener;
4
5
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
6
use Doctrine\ORM\Mapping\ClassMetadata;
7
use Kunstmaan\AdminBundle\Entity\AclChangeset;
8
use Kunstmaan\AdminBundle\EventListener\MappingListener;
9
use PHPUnit\Framework\TestCase;
10
11
class MappingListenerTest extends TestCase
12
{
13
    public function testListener()
14
    {
15
        $args = $this->createMock(LoadClassMetadataEventArgs::class);
16
        $meta = $this->createMock(ClassMetadata::class);
17
18
        $args->expects($this->once())->method('getClassMetadata')->willReturn($meta);
19
        $meta->expects($this->once())->method('getName')->willReturn(AclChangeset::class);
20
        $meta->expects($this->once())->method('mapManyToOne')->willReturn(AclChangeset::class);
21
        $meta->expects($this->once())->method('mapManyToMany')->willReturn(AclChangeset::class);
22
23
        $listener = new MappingListener(AclChangeset::class);
24
        $listener->loadClassMetadata($args);
0 ignored issues
show
Documentation introduced by
$args is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\Even...ClassMetadataEventArgs>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
25
    }
26
}
27