|
@@ 63-94 (lines=32) @@
|
| 60 |
|
/** |
| 61 |
|
* @test |
| 62 |
|
*/ |
| 63 |
|
public function shouldResolveValue() |
| 64 |
|
{ |
| 65 |
|
/** @var ObjectMappingInterface $objectMapping */ |
| 66 |
|
$objectMapping = $this->createMock(ObjectMappingInterface::class); |
| 67 |
|
|
| 68 |
|
/** @var MappingInterface $fieldMapping */ |
| 69 |
|
$fieldMapping = $this->createMock(MappingInterface::class); |
| 70 |
|
|
| 71 |
|
/** @var EntityExample $entity */ |
| 72 |
|
$entity = $this->createMock(EntityExample::class); |
| 73 |
|
|
| 74 |
|
/** @var mixed $dataFromAdditionalColumns */ |
| 75 |
|
$dataFromAdditionalColumns = array( |
| 76 |
|
'lorem' => 'ipsum', |
| 77 |
|
'dolor' => 'sit amet', |
| 78 |
|
); |
| 79 |
|
|
| 80 |
|
$objectMapping->method('getClassName')->willReturn(ValueObjectExample::class); |
| 81 |
|
$objectMapping->method('getFieldMappings')->willReturn([ |
| 82 |
|
'amet' => $fieldMapping |
| 83 |
|
]); |
| 84 |
|
|
| 85 |
|
$this->fieldValueResolver->method('resolveValue')->will($this->returnValueMap([ |
| 86 |
|
[$fieldMapping, $entity, $dataFromAdditionalColumns, "FOO BAR BAZ"], |
| 87 |
|
])); |
| 88 |
|
|
| 89 |
|
/** @var mixed $actualObject */ |
| 90 |
|
$actualObject = $this->valueResolver->resolveValue($objectMapping, $entity, $dataFromAdditionalColumns); |
| 91 |
|
|
| 92 |
|
$this->assertTrue($actualObject instanceof ValueObjectExample); |
| 93 |
|
$this->assertEquals("FOO BAR BAZ", $actualObject->getAmet()); |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
/** |
| 97 |
|
* @test |
|
@@ 99-126 (lines=28) @@
|
| 96 |
|
/** |
| 97 |
|
* @test |
| 98 |
|
*/ |
| 99 |
|
public function shouldRevertValue() |
| 100 |
|
{ |
| 101 |
|
/** @var ObjectMappingInterface $objectMapping */ |
| 102 |
|
$objectMapping = $this->createMock(ObjectMappingInterface::class); |
| 103 |
|
|
| 104 |
|
/** @var MappingInterface $fieldMapping */ |
| 105 |
|
$fieldMapping = $this->createMock(MappingInterface::class); |
| 106 |
|
|
| 107 |
|
/** @var EntityExample $entity */ |
| 108 |
|
$entity = $this->createMock(EntityExample::class); |
| 109 |
|
|
| 110 |
|
$actualObject = new ValueObjectExample("foo"); |
| 111 |
|
$actualObject->setAmet('sit amet'); |
| 112 |
|
|
| 113 |
|
$objectMapping->method('getClassName')->willReturn(ValueObjectExample::class); |
| 114 |
|
$objectMapping->method('getFieldMappings')->willReturn([ |
| 115 |
|
'amet' => $fieldMapping |
| 116 |
|
]); |
| 117 |
|
|
| 118 |
|
$this->fieldValueResolver->method('revertValue')->will($this->returnValueMap([ |
| 119 |
|
[$fieldMapping, $entity, 'sit amet', ['amet' => "FOO BAR BAZ"]], |
| 120 |
|
])); |
| 121 |
|
|
| 122 |
|
/** @var array $actualData */ |
| 123 |
|
$actualData = $this->valueResolver->revertValue($objectMapping, $entity, $actualObject); |
| 124 |
|
|
| 125 |
|
$this->assertEquals(['amet' => "FOO BAR BAZ"], $actualData); |
| 126 |
|
} |
| 127 |
|
|
| 128 |
|
/** |
| 129 |
|
* @test |