for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace SfCod\QueueBundle\Tests\Service;
use PHPUnit\Framework\TestCase;
use SfCod\QueueBundle\Job\JobContractInterface;
use SfCod\QueueBundle\Service\JobProcess;
/**
* Class JobProcessTest
*
* @author Virchenko Maksim <[email protected]>
* @package SfCod\QueueBundle\Tests\Service
*/
class JobProcessTest extends TestCase
{
* Test get process
public function testGetProcess()
$scriptName = uniqid('script_');
$binPath = __DIR__;
$binary = 'php';
$binaryArgs = '';
$jobProcess = new JobProcess($scriptName, $binPath, $binary, $binaryArgs);
$jobId = uniqid('id_');
$jobQueue = uniqid('queue_');
$job = $this->createMock(JobContractInterface::class);
$job
->expects($this->exactly(2))
->method('getJobId')
->will($this->returnValue($jobId));
->method('getQueue')
->will($this->returnValue($jobQueue));
$connectionName = uniqid('connection_');
$process = $jobProcess->getProcess($job, $connectionName);
object<PHPUnit\Framework\MockObject\MockObject>
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);
$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'));
$this->assertEquals($command, $process->getCommandLine());
}
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: