Completed
Push — master ( 0abcb0...7130b4 )
by
unknown
63:00 queued 23:32
created

JobProcessTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 5
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testGetProcess() 0 30 1
1
<?php
2
3
namespace SfCod\QueueBundle\Tests\Service;
4
5
use PHPUnit\Framework\TestCase;
6
use SfCod\QueueBundle\Job\JobContractInterface;
7
use SfCod\QueueBundle\Service\JobProcess;
8
9
/**
10
 * Class JobProcessTest
11
 *
12
 * @author Virchenko Maksim <[email protected]>
13
 *
14
 * @package SfCod\QueueBundle\Tests\Service
15
 */
16
class JobProcessTest extends TestCase
17
{
18
    /**
19
     * Test get process
20
     */
21
    public function testGetProcess()
22
    {
23
        $scriptName = uniqid('script_');
24
        $binPath = __DIR__;
25
        $binary = 'php';
26
        $binaryArgs = '';
27
28
        $jobProcess = new JobProcess($scriptName, $binPath, $binary, $binaryArgs);
29
30
        $jobId = uniqid('id_');
31
        $jobQueue = uniqid('queue_');
32
33
        $job = $this->createMock(JobContractInterface::class);
34
        $job
35
            ->expects($this->exactly(2))
36
            ->method('getJobId')
37
            ->will($this->returnValue($jobId));
38
        $job
39
            ->expects($this->exactly(2))
40
            ->method('getQueue')
41
            ->will($this->returnValue($jobQueue));
42
43
        $connectionName = uniqid('connection_');
44
45
        $process = $jobProcess->getProcess($job, $connectionName);
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...
46
47
        $command = sprintf("'php' %s job-queue:run-job %s --connection=%s --queue=%s --env=%s > /dev/null 2>&1 &", $scriptName, $job->getJobId(), $connectionName, $job->getQueue(), getenv('APP_ENV'));
48
49
        $this->assertEquals($command, $process->getCommandLine());
50
    }
51
}
52