Completed
Push — master ( 2db41f...aa6ae6 )
by Matthew
15:06 queued 36s
created

CreateJobCommandTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 9
dl 0
loc 29
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testCreateJobCommand() 0 24 1
1
<?php
2
3
namespace Dtc\QueueBundle\Tests\Command;
4
5
use Dtc\QueueBundle\Command\CreateJobCommand;
6
use Dtc\QueueBundle\EventDispatcher\EventDispatcher;
7
use Dtc\QueueBundle\Model\Job;
8
use Dtc\QueueBundle\Model\JobTimingManager;
9
use Dtc\QueueBundle\Model\Run;
10
use Dtc\QueueBundle\Model\RunManager;
11
use Dtc\QueueBundle\Model\WorkerManager;
12
use Dtc\QueueBundle\Tests\FibonacciWorker;
13
use Dtc\QueueBundle\Tests\StubJobManager;
14
use PHPUnit\Framework\TestCase;
15
use Symfony\Component\DependencyInjection\Container;
16
17
class CreateJobCommandTest extends TestCase
18
{
19
    use CommandTrait;
20
21
    public function testCreateJobCommand()
22
    {
23
        $jobTimingManager = new JobTimingManager(JobTimingManager::class, false);
24
        $runManager = new RunManager($jobTimingManager, Run::class);
0 ignored issues
show
Unused Code introduced by
The call to RunManager::__construct() has too many arguments starting with \Dtc\QueueBundle\Model\Run::class.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
25
        $jobManager = new StubJobManager($runManager, $jobTimingManager, Job::class);
26
        $container = new Container();
27
        $container->set('dtc_queue.job_manager', $jobManager);
28
        $this->runCommandException(CreateJobCommand::class, $container, ['worker_name' => 'fibonacci', 'method' => 'fibonacci', 'args' => [1]]);
29
30
        $eventDispatcher = new EventDispatcher();
31
        $workerManager = new WorkerManager($jobManager, $eventDispatcher);
32
33
        $container->set('dtc_queue.worker_manager', $workerManager);
34
        $this->runCommandException(CreateJobCommand::class, $container, ['worker_name' => 'fibonacci', 'method' => 'fibonacci', 'args' => [1]]);
35
36
        $worker = new FibonacciWorker();
37
        $worker->setJobManager($jobManager);
38
        $workerManager->addWorker($worker);
39
        $this->runCommand(CreateJobCommand::class, $container, ['worker_name' => 'fibonacci', 'method' => 'fibonacci', 'args' => [1]]);
40
41
        self::assertTrue(isset($jobManager->calls['save'][0][0]));
42
        self::assertTrue($jobManager->calls['save'][0][0] instanceof Job);
43
        self::assertTrue(!isset($jobManager->calls['save'][0][1]));
44
    }
45
}
46