Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

Tests/unit/EventListener/CloneListenerTest.php (2 issues)

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 Kunstmaan\AdminBundle\Entity\DeepCloneInterface;
6
use Kunstmaan\AdminBundle\Event\DeepCloneAndSaveEvent;
7
use Kunstmaan\AdminBundle\EventListener\CloneListener;
8
use Kunstmaan\MediaBundle\Entity\Media;
9
use PHPUnit\Framework\TestCase;
10
11
class CloneListenerTest extends TestCase
12
{
13
    public function testListener()
14
    {
15
        $listener = new CloneListener();
16
        $user = new Media();
17
        $user->setId(666);
18
        $dc = $this->createMock(DeepCloneInterface::class);
19
        $dc->expects($this->once())->method('deepClone')->willReturn(true);
20
        $event = $this->createMock(DeepCloneAndSaveEvent::class);
21
        $event->expects($this->any())->method('getClonedEntity')->willReturn($user);
22
23
        $listener->onDeepCloneAndSave($event);
0 ignored issues
show
$event is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminBu...\DeepCloneAndSaveEvent>.

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...
24
        $this->assertNull($user->getId());
25
26
        $event = $this->createMock(DeepCloneAndSaveEvent::class);
27
        $event->expects($this->any())->method('getClonedEntity')->willReturn($dc);
28
29
        $listener->onDeepCloneAndSave($event);
0 ignored issues
show
$event is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\AdminBu...\DeepCloneAndSaveEvent>.

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...
30
    }
31
}
32