Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

Tests/unit/Event/RevertNodeActionTest.php (3 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\RevertNodeAction;
10
use PHPUnit\Framework\TestCase;
11
use Symfony\Component\HttpFoundation\Response;
12
13
/**
14
 * Class RevertNodeActionTest
15
 */
16
class RevertNodeActionTest extends TestCase
17
{
18
    public function testGetSet()
19
    {
20
        /** @var Node $node */
21
        $node = $this->createMock(Node::class);
22
        /** @var NodeTranslation $nodeTranslation */
23
        $nodeTranslation = $this->createMock(NodeTranslation::class);
24
        /** @var NodeVersion $nodeVersion */
25
        $nodeVersion = $this->createMock(NodeVersion::class);
26
        $page = $this->createMock(HasNodeInterface::class);
27
28
        $event = new RevertNodeAction($node, $nodeTranslation, $nodeVersion, $page, $nodeVersion, $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...
29
30
        $this->assertInstanceOf(Node::class, $event->getNode());
31
        $this->assertInstanceOf(NodeTranslation::class, $event->getNodeTranslation());
32
        $this->assertInstanceOf(NodeVersion::class, $event->getNodeVersion());
33
        $this->assertInstanceOf(\get_class($page), $event->getPage());
34
        $this->assertInstanceOf(NodeVersion::class, $event->getOriginNodeVersion());
35
        $this->assertInstanceOf(\get_class($page), $event->getOriginPage());
36
37
        $event->setNode($node);
38
        $event->setNodeTranslation($nodeTranslation);
39
        $event->setNodeVersion($nodeVersion);
40
        $event->setPage($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...
41
        $event->setResponse(new Response());
42
        $event->setOriginNodeVersion($nodeVersion);
43
        $event->setOriginPage($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...
44
45
        $this->assertInstanceOf(Node::class, $event->getNode());
46
        $this->assertInstanceOf(NodeTranslation::class, $event->getNodeTranslation());
47
        $this->assertInstanceOf(\get_class($page), $event->getPage());
48
        $this->assertInstanceOf(NodeVersion::class, $event->getNodeVersion());
49
        $this->assertInstanceOf(Response::class, $event->getResponse());
50
        $this->assertInstanceOf(NodeVersion::class, $event->getOriginNodeVersion());
51
        $this->assertInstanceOf(\get_class($page), $event->getOriginPage());
52
    }
53
}
54