Completed
Pull Request — master (#6)
by
unknown
01:16
created

JobResolverTest::mockResolver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace SfCod\QueueBundle\Tests\Service;
4
5
use PHPUnit\Framework\TestCase;
6
use SfCod\QueueBundle\Base\JobInterface;
7
use SfCod\QueueBundle\Service\JobResolver;
8
9
/**
10
 * Class JobResolverTest
11
 *
12
 * @author Virchenko Maksim <[email protected]>
13
 *
14
 * @package SfCod\QueueBundle\Tests\Service
15
 */
16
class JobResolverTest extends TestCase
17
{
18
    /**
19
     * Test resolve job by name
20
     */
21
    public function testResolve()
22
    {
23
        $jobName = uniqid('job_');
24
        $jobClass = $this->createMock(JobInterface::class);
25
26
        $resolver = new JobResolver();
27
        $resolver->addJob($jobName, $jobClass);
0 ignored issues
show
Documentation introduced by
$jobClass is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<SfCod\QueueBundle\Base\JobInterface>.

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::assertEquals($jobClass, $resolver->resolve($jobName));
30
    }
31
}
32