Completed
Push — master ( c76232...ce4950 )
by Matthew
27:26 queued 01:28
created

RunManagerTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 59.09 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 26
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetRunClass() 0 5 1
A testSetRunClass() 0 7 1
A testPruneArchiveRuns() 13 13 2
A testPruneStalledRuns() 13 13 2

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\Manager;
4
5
use Dtc\QueueBundle\Exception\UnsupportedException;
6
use Dtc\QueueBundle\Manager\RunManager;
7
use Dtc\QueueBundle\Model\Run;
8
use PHPUnit\Framework\TestCase;
9
10
class RunManagerTest extends TestCase
11
{
12
    public function testGetRunClass()
13
    {
14
        $runManager = new RunManager(Run::class);
15
        self::assertEquals(Run::class, $runManager->getRunClass());
16
    }
17
18
    public function testSetRunClass()
19
    {
20
        $runManager = new RunManager(Run::class);
21
        self::assertEquals(Run::class, $runManager->getRunClass());
22
        $runManager->setRunClass(\Dtc\QueueBundle\Entity\Run::class);
23
        self::assertEquals(\Dtc\QueueBundle\Entity\Run::class, $runManager->getRunClass());
24
    }
25
26 View Code Duplication
    public function testPruneArchiveRuns()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $runManager = new RunManager(Run::class);
29
30
        $failure = false;
31
        try {
32
            $runManager->pruneArchivedRuns(new \DateTime());
33
            $failure = true;
34
        } catch (UnsupportedException $exception) {
35
            self::assertNotNull($exception);
36
        }
37
        self::assertFalse($failure);
38
    }
39
40 View Code Duplication
    public function testPruneStalledRuns()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
    {
42
        $runManager = new RunManager(Run::class);
43
44
        $failure = false;
45
        try {
46
            $runManager->pruneStalledRuns();
47
            $failure = true;
48
        } catch (UnsupportedException $exception) {
49
            self::assertNotNull($exception);
50
        }
51
        self::assertFalse($failure);
52
    }
53
}
54