mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-28 08:20:00 +01:00
52 lines
1.4 KiB
PHP
52 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Wallabag\Form\DataTransformer;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Wallabag\Form\DataTransformer\StringToListTransformer;
|
|
|
|
class StringToListTransformerTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider transformProvider
|
|
*/
|
|
public function testTransformWithValidData($inputData, $expectedResult)
|
|
{
|
|
$transformer = new StringToListTransformer();
|
|
|
|
$this->assertSame($expectedResult, $transformer->transform($inputData));
|
|
}
|
|
|
|
public function transformProvider()
|
|
{
|
|
return [
|
|
[null, ''],
|
|
[[], ''],
|
|
[['single value'], 'single value'],
|
|
[['first value', 'second value'], 'first value,second value'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider reverseTransformProvider
|
|
*/
|
|
public function testReverseTransformWithValidData($inputData, $expectedResult)
|
|
{
|
|
$transformer = new StringToListTransformer();
|
|
|
|
$this->assertSame($expectedResult, $transformer->reverseTransform($inputData));
|
|
}
|
|
|
|
public function reverseTransformProvider()
|
|
{
|
|
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']],
|
|
];
|
|
}
|
|
}
|