ContextMergeConverterTest::getConvertData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Mathielen\DataImport\ItemConverter;
3
4
use Mathielen\DataImport\Event\ImportProcessEvent;
5
use Mathielen\ImportEngine\Import\Import;
6
use Mathielen\ImportEngine\ValueObject\ImportRun;
7
8
class ContextMergeConverterTest extends \PHPUnit_Framework_TestCase
9
{
10
11
    /**
12
     * @var ContextMergeConverter
13
     */
14
    private $sut;
15
16
    protected function setUp()
17
    {
18
        $this->sut = new ContextMergeConverter();
19
    }
20
21
    /**
22
     * @dataProvider getConvertData
23
     */
24
    public function testConvert(ImportProcessEvent $event, array $inputData, array $expectedResult)
25
    {
26
        $this->sut->onImportPrepare($event);
27
28
        $this->assertEquals($expectedResult, $this->sut->convert($inputData));
29
    }
30
31
    public function getConvertData()
32
    {
33
        return array(
34
            array(
35
                new ImportProcessEvent(),
36
                array('a'=>1),
37
                array('a'=>1)
38
            ),
39
            array(
40
                $this->createEvent(),
41
                array('a'=>1),
42
                array('a'=>1)
43
            ),
44
            array(
45
                $this->createEvent(ImportRun::create()->setContext('string')),
46
                array('a'=>1),
47
                array('a'=>1)
48
            ),
49
            array(
50
                $this->createEvent(ImportRun::create()->setContext(array('b'=>2))),
51
                array('a'=>1),
52
                array('a'=>1, 'b'=>2)
53
            ),
54
        );
55
    }
56
57
    private function createEvent($importRun=null)
58
    {
59
        return new ImportProcessEvent(
60
            new Import(
61
                $this->createMock('Mathielen\ImportEngine\Importer\ImporterInterface'),
62
                $this->createMock('Mathielen\ImportEngine\Storage\StorageInterface'),
63
                $importRun
64
            )
65
        );
66
    }
67
68
}
69