DeleteTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 5
dl 0
loc 53
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetCode() 0 9 1
A getResource() 0 9 2
A testProcess() 0 11 1
A testWrongProcess() 0 9 1
1
<?php
2
3
namespace Maketok\DataMigration\Action\Type;
4
5
use Maketok\DataMigration\Storage\Db\ResourceInterface;
6
7
class DeleteTest extends \PHPUnit_Framework_TestCase
8
{
9
    use ServiceGetterTrait;
10
11
    public function testGetCode()
12
    {
13
        $action = new Delete(
14
            $this->getUnitBag(),
15
            $this->getConfig(),
16
            $this->getResource()
17
        );
18
        $this->assertEquals('delete', $action->getCode());
19
    }
20
21
    /**
22
     * @param bool $expects
23
     * @return ResourceInterface
24
     */
25
    protected function getResource($expects = false)
26
    {
27
        $resource = $this->getMockBuilder('\Maketok\DataMigration\Storage\Db\ResourceInterface')
28
            ->getMock();
29
        if ($expects) {
30
            $resource->expects($this->atLeastOnce())->method('deleteUsingTempPK');
31
        }
32
        return $resource;
33
    }
34
35
    public function testProcess()
36
    {
37
        $unit = $this->getUnit('tmp');
38
        $unit->setTmpTable('tmp1');
39
        $action = new Delete(
40
            $this->getUnitBag([$unit]),
41
            $this->getConfig(),
42
            $this->getResource(true)
43
        );
44
        $action->process($this->getResultMock());
45
    }
46
47
    /**
48
     * @expectedException \Maketok\DataMigration\Action\Exception\WrongContextException
49
     */
50
    public function testWrongProcess()
51
    {
52
        $action = new Delete(
53
            $this->getUnitBag([$this->getUnit('tmp')]),
54
            $this->getConfig(),
55
            $this->getResource()
56
        );
57
        $action->process($this->getResultMock());
58
    }
59
}
60