2015-10-12 21:43:24 +02:00
|
|
|
<?php
|
|
|
|
|
2024-02-19 01:30:12 +01:00
|
|
|
namespace Tests\Wallabag\Form\DataTransformer;
|
2015-10-12 21:43:24 +02:00
|
|
|
|
2017-12-16 22:38:07 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2024-02-19 01:30:12 +01:00
|
|
|
use Wallabag\Form\DataTransformer\StringToListTransformer;
|
2015-10-12 21:43:24 +02:00
|
|
|
|
2017-12-16 22:38:07 +01:00
|
|
|
class StringToListTransformerTest extends TestCase
|
2015-10-12 21:43:24 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider transformProvider
|
|
|
|
*/
|
|
|
|
public function testTransformWithValidData($inputData, $expectedResult)
|
|
|
|
{
|
|
|
|
$transformer = new StringToListTransformer();
|
|
|
|
|
|
|
|
$this->assertSame($expectedResult, $transformer->transform($inputData));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function transformProvider()
|
|
|
|
{
|
2016-04-12 11:36:01 +02:00
|
|
|
return [
|
|
|
|
[null, ''],
|
|
|
|
[[], ''],
|
|
|
|
[['single value'], 'single value'],
|
|
|
|
[['first value', 'second value'], 'first value,second value'],
|
|
|
|
];
|
2015-10-12 21:43:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider reverseTransformProvider
|
|
|
|
*/
|
|
|
|
public function testReverseTransformWithValidData($inputData, $expectedResult)
|
|
|
|
{
|
|
|
|
$transformer = new StringToListTransformer();
|
|
|
|
|
|
|
|
$this->assertSame($expectedResult, $transformer->reverseTransform($inputData));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function reverseTransformProvider()
|
|
|
|
{
|
2016-04-12 11:36:01 +02:00
|
|
|
return [
|
|
|
|
[null, null],
|
|
|
|
['', []],
|
|
|
|
['single value', ['single value']],
|
|
|
|
['first value,second value', ['first value', 'second value']],
|
|
|
|
['first value, second value', ['first value', 'second value']],
|
|
|
|
['first value, , second value', ['first value', 'second value']],
|
|
|
|
];
|
2015-10-12 21:43:24 +02:00
|
|
|
}
|
|
|
|
}
|