Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

EZP-31808: Added conversion from string to int in RelationListValueTransformer::reverseTransform #30

Merged
merged 1 commit into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function reverseTransform($value)

$destinationContentIds = explode(',', $value);
$destinationContentIds = array_map('trim', $destinationContentIds);
$destinationContentIds = array_map('intval', $destinationContentIds);

return new Value($destinationContentIds);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace EzSystems\EzPlatformContentForms\Tests\FieldType\DataTransformer;

use eZ\Publish\Core\FieldType\RelationList\Value;
use EzSystems\EzPlatformContentForms\FieldType\DataTransformer\RelationListValueTransformer;
use PHPUnit\Framework\TestCase;

final class RelationListValueTransformerTest extends TestCase
{
/**
* @dataProvider dataProviderForTestReverseTransform
*/
public function testReverseTransform($value, ?Value $expectedValue): void
{
$transformer = new RelationListValueTransformer();

$this->assertEquals(
$expectedValue,
$transformer->reverseTransform($value)
);
}

public function dataProviderForTestReverseTransform(): iterable
{
yield 'null' => [
null,
null,
];

yield 'optimistic' => [
'1,2,3,5,8,13',
new Value([1, 2, 3, 5, 8, 13]),
];
}
}