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;
use SfCod\QueueBundle\Worker\Options;
/**
* 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__;
$jobProcess = new JobProcess($scriptName, $binPath);
$jobId = uniqid('id_');
$jobQueue = uniqid('queue_');
$job = $this->createMock(JobContractInterface::class);
$job
->expects(self::exactly(2))
->method('getJobId')
->willReturn($jobId);
->method('getQueue')
->willReturn($jobQueue);
$connectionName = uniqid('connection_');
->method('getConnectionName')
->willReturn($connectionName);
$process = $jobProcess->getProcess($job, new Options());
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('%s %s job-queue:run-job %s --connection=%s --queue=%s --env=%s --delay=0 --memory=128 --timeout=60 --sleep=3 --maxTries=0 > /dev/null 2>&1 &', 'php', $binPath . DIRECTORY_SEPARATOR . $scriptName, $job->getJobId(), $connectionName, $job->getQueue(), 'prod');
self::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: