|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Maketok\DataMigration\Action\Type; |
|
4
|
|
|
|
|
5
|
|
|
use Maketok\DataMigration\Action\ConfigInterface; |
|
6
|
|
|
use Maketok\DataMigration\Unit\AbstractUnit; |
|
7
|
|
|
use Maketok\DataMigration\Unit\SimpleBag; |
|
8
|
|
|
use Maketok\DataMigration\Unit\Type\Unit; |
|
9
|
|
|
use Maketok\DataMigration\Unit\UnitBagInterface; |
|
10
|
|
|
use Maketok\DataMigration\Workflow\ResultInterface; |
|
11
|
|
|
|
|
12
|
|
|
trait ServiceGetterTrait |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param AbstractUnit[] $units |
|
16
|
|
|
* @return UnitBagInterface |
|
17
|
|
|
*/ |
|
18
|
38 |
|
protected function getUnitBag($units = []) |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var \PHPUnit_Framework_TestCase $this */ |
|
21
|
38 |
|
$unitBag = new SimpleBag(); |
|
22
|
38 |
|
foreach ($units as $unit) { |
|
23
|
29 |
|
$unitBag->add($unit); |
|
24
|
38 |
|
} |
|
25
|
38 |
|
return $unitBag; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @return ConfigInterface |
|
30
|
|
|
*/ |
|
31
|
38 |
|
protected function getConfig() |
|
32
|
|
|
{ |
|
33
|
|
|
/** @var \PHPUnit_Framework_TestCase $this */ |
|
34
|
38 |
|
$config = $this->getMockBuilder('\Maketok\DataMigration\Action\ConfigInterface') |
|
35
|
38 |
|
->getMock(); |
|
36
|
38 |
|
$config->expects($this->any())->method('offsetGet')->willReturnMap([ |
|
37
|
38 |
|
['tmp_folder', '/tmp'], |
|
38
|
38 |
|
['tmp_file_mask', '%1$s.csv'], // fname, date |
|
39
|
38 |
|
['dump_limit', '10000'], |
|
40
|
38 |
|
['tmp_table_mask', 'tmp_%1$s%2$s'], // fname, stamp |
|
41
|
38 |
|
]); |
|
42
|
38 |
|
return $config; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return ResultInterface |
|
47
|
|
|
*/ |
|
48
|
27 |
|
protected function getResultMock() |
|
49
|
|
|
{ |
|
50
|
|
|
/** @var \PHPUnit_Framework_TestCase $this */ |
|
51
|
27 |
|
return $this->getMockBuilder('\Maketok\DataMigration\Workflow\ResultInterface')->getMock(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param string $code |
|
56
|
|
|
* @return Unit |
|
57
|
|
|
*/ |
|
58
|
19 |
|
public function getUnit($code) |
|
59
|
|
|
{ |
|
60
|
19 |
|
return new Unit($code); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|