JobProcessingEventTest::testEvent()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SfCod\QueueBundle\Tests\Event;
4
5
use PHPUnit\Framework\TestCase;
6
use SfCod\QueueBundle\Event\JobProcessingEvent;
7
use SfCod\QueueBundle\Job\JobContractInterface;
8
use Symfony\Contracts\EventDispatcher\Event;
9
10
/**
11
 * Class JobProcessingEventTest
12
 *
13
 * @author Virchenko Maksim <[email protected]>
14
 *
15
 * @package SfCod\QueueBundle\Tests\Event
16
 */
17
class JobProcessingEventTest extends TestCase
18
{
19
    /**
20
     * Test event
21
     */
22
    public function testEvent()
23
    {
24
        $connectionName = uniqid('connection_');
25
        $job = $this->createMock(JobContractInterface::class);
26
27
        $event = new JobProcessingEvent($connectionName, $job);
0 ignored issues
show
Documentation introduced by
$job is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<SfCod\QueueBundle...b\JobContractInterface>.

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...
28
29
        self::assertInstanceOf(Event::class, $event);
30
        self::assertEquals($connectionName, $event->getConnectionName());
31
        self::assertEquals($job, $event->getJob());
32
    }
33
}
34