Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

Commit

Permalink
bug #33 Fix SingleMappingTransformer not working with null (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

|Q            |A  |
|---          |---|
|Bug Fix?     |yes|
|New Feature? |no |
|BC Breaks?   |no |
|Deprecations?|no |
|Fixed Tickets|   |

Commits
-------

7dfe95b Fix SingleMappingTransformer not working with null
  • Loading branch information
sstok committed Oct 31, 2015
2 parents c6ff148 + 7dfe95b commit e69e48e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function transform($value)

// If there is only one field but is does not exist the value
// is assumed to be an array-value and not a data-mapping result.
if (!isset($value[key($this->mappingFields)])) {
if (!array_key_exists(key($this->mappingFields), $value)) {
return $value;
}

Expand Down
17 changes: 17 additions & 0 deletions tests/Extension/Core/ColumnType/TextTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ public function testEmptyValueOption()
$this->assertCellValueEquals(' - foo - , - ? - ', $data, $options);
}

public function testEmptyValueOptionSingleField()
{
$object = new \stdClass();
$object->key = 'foo';
$object->key2 = null;
$data = [1 => $object];

$options = [
'field_mapping' => ['key'],
'value_format' => ' - %s - ',
'empty_value' => '?',
'value_glue' => ',',
];

$this->assertCellValueEquals(' - foo - ', $data, $options);
}

public function testEmptyValueAsArrayOption()
{
$object = new \stdClass();
Expand Down

0 comments on commit e69e48e

Please sign in to comment.