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

UnknownPropertiesItemConverterTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 41
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConvert() 0 6 1
A testFromClass() 0 6 1
A getConvertData() 0 19 1
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