Completed
Push — master ( 0473d3...bc9ba5 )
by Markus
24:46
created

testFromClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace Mathielen\DataImport\ItemConverter;
3
4
use TestEntities\Address;
5
6
class UnknownPropertiesItemConverterTest extends \PHPUnit_Framework_TestCase
7
{
8
9
    /**
10
     * @dataProvider getConvertData
11
     */
12
    public function testConvert(array $knownProperties, $targetProperty, $skipEmptyKey, $inputData, array $expectedResult)
13
    {
14
        $converter = new UnknownPropertiesItemConverter($knownProperties, $targetProperty, $skipEmptyKey);
15
16
        $this->assertEquals($expectedResult, $converter->convert($inputData));
17
    }
18
19
    public function testFromClass()
20
    {
21
        $converter = UnknownPropertiesItemConverter::fromClass(Address::class);
22
23
        $this->assertEquals(['name'=>1,'ATTRIBUTES'=>['unknown'=>1]], $converter->convert(['name'=>1, 'unknown'=>1]));
24
    }
25
26
    public function getConvertData()
27
    {
28
        return array(
29
            array(
30
                array('a', 'b'),
31
                'target',
32
                true,
33
                array('a'=>1, 'b'=>2, 'c'=>3, ''=>''),
34
                array('a'=>1, 'b'=>2, 'target'=>array('c'=>3))
35
            ),
36
            array(
37
                array('a', 'b'),
38
                'target',
39
                false,
40
                array('a'=>1, 'b'=>2, ''=>''),
41
                array('a'=>1, 'b'=>2, 'target'=>array(''=>''))
42
            )
43
        );
44
    }
45
46
}
47