Completed
Push — master ( ea9d41...184c59 )
by Sergii
08:21
created

ProcessorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 80.77 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 8
dl 42
loc 52
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testAdd() 11 11 1
A testUpdate() 11 11 1
A testDelete() 11 11 1
A testInvalidTask() 9 9 1

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
namespace Tests\AppBundle\Sync;
3
4
use AppBundle\Sync\Entity\Task;
5
use AppBundle\Sync\Processor;
6
use AppBundle\Sync\Entity\Task\Add;
7
use AppBundle\Sync\Entity\Task\Delete;
8
use AppBundle\Sync\Entity\Task\Update;
9
use AppBundle\Sync\Storage\StorageInterface;
10
11
/**
12
 * Task Processor tests
13
 *
14
 * @author Sergey Sadovoi <[email protected]>
15
 */
16
class ProcessorTest extends \PHPUnit_Framework_TestCase
17
{
18 View Code Duplication
    public function testAdd()
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...
19
    {
20
        $storage = $this->getMockForAbstractClass(StorageInterface::class);
21
        $storage->expects($this->once())
22
                ->method('put');
23
24
        $processor = new Processor($storage);
25
        $task = new Add();
26
27
        $processor->execute($task);
28
    }
29
30 View Code Duplication
    public function testUpdate()
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...
31
    {
32
        $storage = $this->getMockForAbstractClass(StorageInterface::class);
33
        $storage->expects($this->once())
34
                ->method('put');
35
36
        $processor = new Processor($storage);
37
        $task = new Update();
38
39
        $processor->execute($task);
40
    }
41
42 View Code Duplication
    public function testDelete()
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...
43
    {
44
        $storage = $this->getMockForAbstractClass(StorageInterface::class);
45
        $storage->expects($this->once())
46
                ->method('delete');
47
48
        $processor = new Processor($storage);
49
        $task = new Delete();
50
51
        $processor->execute($task);
52
    }
53
54
    /**
55
     * @expectedException \AppBundle\Exception\TaskException
56
     * @expectedExceptionCode \AppBundle\Exception\TaskException::INVALID_TASK
57
     */
58 View Code Duplication
    public function testInvalidTask()
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...
59
    {
60
        $storage = $this->getMockForAbstractClass(StorageInterface::class);
61
        $processor = new Processor($storage);
62
        $task = $this->getMockBuilder(Task::class)
63
            ->getMock();
64
65
        $processor->execute($task);
66
    }
67
}
68