ReverseMoveTest::getResource()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.9332
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Maketok\DataMigration\Action\Type;
4
5
use Maketok\DataMigration\Storage\Db\ResourceInterface;
6
use Maketok\DataMigration\Unit\Type\Unit;
7
8
class ReverseMoveTest extends \PHPUnit_Framework_TestCase
9
{
10
    use ServiceGetterTrait;
11
12
    public function testGetCode()
13
    {
14
        $action = new ReverseMove(
15
            $this->getUnitBag(),
16
            $this->getConfig(),
17
            $this->getResource()
18
        );
19
        $this->assertEquals('reverse_move', $action->getCode());
20
    }
21
22
    /**
23
     * @param string $code
24
     * @return Unit
25
     */
26
    public function getUnit($code)
27
    {
28
        $unit = new Unit($code);
29
        $unit->setReverseMoveConditions([
30
            "id != 5"
31
        ]);
32
        $unit->setReverseMoveOrder([
33
            'id'
34
        ]);
35
        $unit->setReverseMoveDirection('desc');
36
        return $unit;
37
    }
38
39
    /**
40
     * @param bool $expects
41
     * @return ResourceInterface
42
     */
43
    protected function getResource($expects = false)
44
    {
45
        $resource = $this->getMockBuilder('\Maketok\DataMigration\Storage\Db\ResourceInterface')
46
            ->getMock();
47
        if ($expects) {
48
            $resource->expects($this->atLeastOnce())
49
                ->method('move');
50
        }
51
        return $resource;
52
    }
53
54
    public function testProcess()
55
    {
56
        $unit = $this->getUnit('tmp');
57
        $action = new ReverseMove(
58
            $this->getUnitBag([$unit]),
59
            $this->getConfig(),
60
            $this->getResource(true)
61
        );
62
        $action->process($this->getResultMock());
63
64
        $this->assertNotEmpty($unit->getTmpTable());
65
    }
66
}
67