Completed
Push — master ( ae5e03...0447ee )
by Jeroen
10:35 queued 04:37
created

unit/Event/RecopyPageTranslationNodeEventTest.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\NodeBundle\Tests\Event;
4
5
use Kunstmaan\NodeBundle\Entity\HasNodeInterface;
6
use Kunstmaan\NodeBundle\Entity\Node;
7
use Kunstmaan\NodeBundle\Entity\NodeTranslation;
8
use Kunstmaan\NodeBundle\Entity\NodeVersion;
9
use Kunstmaan\NodeBundle\Event\RecopyPageTranslationNodeEvent;
10
use PHPUnit\Framework\TestCase;
11
12
/**
13
 * Class RecopyPageTranslationNodeEventTest
14
 */
15 View Code Duplication
class RecopyPageTranslationNodeEventTest extends TestCase
16
{
17
    public function testGetSet()
18
    {
19
        /** @var Node $node */
20
        $node = $this->createMock(Node::class);
21
        /** @var NodeTranslation $nodeTranslation */
22
        $nodeTranslation = $this->createMock(NodeTranslation::class);
23
        /** @var NodeVersion $nodeVersion */
24
        $nodeVersion = $this->createMock(NodeVersion::class);
25
26
        $page = $this->createMock(HasNodeInterface::class);
27
28
        $event = new RecopyPageTranslationNodeEvent($node, $nodeTranslation, $nodeVersion, $page, $nodeTranslation, $nodeVersion, $page, 'nl');
0 ignored issues
show
$page is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\NodeBun...ntity\HasNodeInterface>.

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...
29
30
        $this->assertEquals('nl', $event->getOriginalLanguage());
31
        $this->assertInstanceOf(NodeTranslation::class, $event->getOriginalNodeTranslation());
32
        $this->assertInstanceOf(\get_class($page), $event->getOriginalPage());
33
        $this->assertInstanceOf(NodeVersion::class, $event->getOriginalNodeVersion());
34
35
        $event->setOriginalLanguage('nl');
36
        $event->setOriginalNodeTranslation($nodeTranslation);
37
        $event->setOriginalNodeVersion($nodeVersion);
38
        $event->setOriginalPage($page);
0 ignored issues
show
$page is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\NodeBun...ntity\HasNodeInterface>.

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...
39
40
        $this->assertEquals('nl', $event->getOriginalLanguage());
41
        $this->assertInstanceOf(NodeTranslation::class, $event->getOriginalNodeTranslation());
42
        $this->assertInstanceOf(\get_class($page), $event->getOriginalPage());
43
        $this->assertInstanceOf(NodeVersion::class, $event->getOriginalNodeVersion());
44
    }
45
}
46