ContextMergeConverterTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 61
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testConvert() 0 6 1
A getConvertData() 0 25 1
A createEvent() 0 10 1
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