MoveTest::testGetCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.9666
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Maketok\DataMigration\Action\Type;
4
5
use Maketok\DataMigration\Storage\Db\ResourceInterface;
6
7
class MoveTest extends \PHPUnit_Framework_TestCase
8
{
9
    use ServiceGetterTrait;
10
11
    public function testGetCode()
12
    {
13
        $action = new Move(
14
            $this->getUnitBag(),
15
            $this->getConfig(),
16
            $this->getResource()
17
        );
18
        $this->assertEquals('move', $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())
31
                ->method('move');
32
        }
33
        return $resource;
34
    }
35
36
    public function testProcess()
37
    {
38
        $unit = $this->getUnit('test');
39
        $unit->setTmpTable('tmp');
40
        $action = new Move(
41
            $this->getUnitBag([$unit]),
42
            $this->getConfig(),
43
            $this->getResource(true)
44
        );
45
        $action->process($this->getResultMock());
46
    }
47
48
    /**
49
     * @expectedException \Maketok\DataMigration\Action\Exception\WrongContextException
50
     * @expectedExceptionMessage Action can not be used for current unit test
51
     */
52
    public function testWrongProcess()
53
    {
54
        $action = new Move(
55
            $this->getUnitBag([$this->getUnit('test')]),
56
            $this->getConfig(),
57
            $this->getResource()
58
        );
59
        $action->process($this->getResultMock());
60
    }
61
}
62