Completed
Push — master ( 6d6774...64f3ed )
by Jeroen
11:23 queued 05:13
created

Tests/unit/EventListener/MappingListenerTest.php (1 issue)

mismatching argument types.

Documentation Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
        $meta->table = ['name' => 'test_table'];
19
20
        $args->expects($this->once())->method('getClassMetadata')->willReturn($meta);
21
        $meta->expects($this->once())->method('getName')->willReturn(AclChangeset::class);
22
        $meta->expects($this->once())->method('mapManyToOne')->willReturn(AclChangeset::class);
23
        $meta->expects($this->once())->method('mapManyToMany')->willReturn(AclChangeset::class);
24
25
        $listener = new MappingListener(AclChangeset::class);
26
        $listener->loadClassMetadata($args);
0 ignored issues
show
$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...
27
    }
28
}
29