Passed
Push — master ( f67228...ea1bad )
by Matthew
08:44
created

CountCommandTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 60 %

Coupling/Cohesion

Components 1
Dependencies 9

Importance

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

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Dtc\QueueBundle\Tests\Command;
4
5
use Dtc\QueueBundle\Command\CountCommand;
6
use Dtc\QueueBundle\Model\Job;
7
use Dtc\QueueBundle\Model\JobTiming;
8
use Dtc\QueueBundle\Manager\JobTimingManager;
9
use Dtc\QueueBundle\Model\Run;
10
use Dtc\QueueBundle\Manager\RunManager;
11
use Dtc\QueueBundle\Tests\Beanstalkd\JobManagerTest;
12
use Dtc\QueueBundle\Tests\StubJobManager;
13
use PHPUnit\Framework\TestCase;
14
use Symfony\Component\DependencyInjection\Container;
15
16
class CountCommandTest extends TestCase
17
{
18
    use CommandTrait;
19
20
    public function testCountCommand()
21
    {
22
        $container = new Container();
23
        $jobTimingManager = new JobTimingManager(JobTiming::class, false);
24
        $runManager = new RunManager($jobTimingManager, Run::class);
25
        $container->set('dtc_queue.manager.job', new StubJobManager($runManager, $jobTimingManager, Job::class));
26
        $this->runCommandException(CountCommand::class, $container, []);
27
    }
28
29
    public function testCountBeanstalkdCommand()
30
    {
31
        JobManagerTest::setUpBeforeClass();
32
        $jobManager = JobManagerTest::$jobManager;
33
        $container = new Container();
34
        $container->set('dtc_queue.manager.job', $jobManager);
35
        $this->runCommand(CountCommand::class, $container, []);
36
    }
37
38
    public function testCountMongodbCommand()
39
    {
40
        \Dtc\QueueBundle\Tests\ODM\JobManagerTest::setUpBeforeClass();
41
        $jobManager = \Dtc\QueueBundle\Tests\ODM\JobManagerTest::$jobManager;
42
        $container = new Container();
43
        $container->set('dtc_queue.manager.job', $jobManager);
44
        $this->runCommand(CountCommand::class, $container, []);
45
    }
46
47
    public function testCountORMCommand()
48
    {
49
        \Dtc\QueueBundle\Tests\ORM\JobManagerTest::setUpBeforeClass();
50
        $jobManager = \Dtc\QueueBundle\Tests\ORM\JobManagerTest::$jobManager;
51
        $container = new Container();
52
        $container->set('dtc_queue.manager.job', $jobManager);
53
        $this->runCommand(CountCommand::class, $container, []);
54
    }
55
}
56