ArrayTest::test()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 40
rs 9.28
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Mathielen\ImportEngine;
3
4
use Mathielen\ImportEngine\Import\Import;
5
use Mathielen\ImportEngine\Import\Run\ImportRunner;
6
use Mathielen\ImportEngine\Importer\Importer;
7
use Mathielen\ImportEngine\Storage\ArrayStorage;
8
use Mathielen\ImportEngine\ValueObject\ImportConfiguration;
9
use Mathielen\ImportEngine\ValueObject\ImportRun;
10
11
class ArrayTest extends \PHPUnit_Framework_TestCase
12
{
13
14
    /**
15
     * @medium
16
     */
17
    public function test()
18
    {
19
        $data = array(
20
            array(
21
                'foo' => 'bar',
22
                'baz' => array(
23
                    'some' => 'value'
24
                )
25
            )
26
        );
27
        $targetData = array();
28
29
        $sourceStorage = new ArrayStorage($data);
30
        $targetStorage = new ArrayStorage($targetData);
31
32
        $importer = Importer::build($targetStorage);
33
34
        $importConfiguration = new ImportConfiguration();
35
        $importRun = $importConfiguration->toRun();
36
37
        $import = Import::build($importer, $sourceStorage, $importRun);
38
        $import
39
            ->mappings()
40
            ->add('foo', 'fooloo')
41
            ->add('baz', array('some' => 'else'));
42
43
        ImportRunner::build()
44
            ->run($import);
45
46
        $expectedData = array(
47
            array(
48
                'fooloo' => 'bar',
49
                'baz'    => array(
50
                    'else' => 'value'
51
                )
52
            )
53
        );
54
55
        $this->assertEquals($expectedData, $targetData);
56
    }
57
58
}
59