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

Tests/unit/Event/SubmissionEventTest.php (1 issue)

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\FormBundle\Tests\Event;
4
5
use Kunstmaan\FormBundle\Entity\AbstractFormPage;
6
use Kunstmaan\FormBundle\Entity\FormSubmission;
7
use Kunstmaan\FormBundle\Event\SubmissionEvent;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class SubmissionEventTest
12
 */
13
class SubmissionEventTest extends TestCase
14
{
15
    public function testEvent()
16
    {
17
        $submission = new FormSubmission();
18
        $page = $this->createMock(AbstractFormPage::class);
19
        $page->method('getId')->willReturn(2);
20
21
        $submission->setId(1);
22
23
        $event = new SubmissionEvent($submission, $page);
0 ignored issues
show
$page is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Kunstmaan\FormBun...lper\FormPageInterface>.

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->assertInstanceOf(FormSubmission::class, $event->getSubmission());
25
        $this->assertEquals($page, $event->getPage());
26
        $this->assertEquals(1, $event->getSubmission()->getId());
27
    }
28
}
29