wallabag/tests/Form/DataTransformer/StringToListTransformerTest.php

52 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2024-02-19 01:30:12 +01:00
namespace Tests\Wallabag\Form\DataTransformer;
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;
2017-12-16 22:38:07 +01:00
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']],
];
}
}