diff options
author | Kévin Gomez <contact@kevingomez.fr> | 2015-10-12 21:43:24 +0200 |
---|---|---|
committer | Kévin Gomez <contact@kevingomez.fr> | 2015-11-11 16:23:49 +0100 |
commit | 003fa77438b13ceb9ceda245d6ad257801453d27 (patch) | |
tree | 6c7d375a3de3efd5c98f312a717fa02b6a97d19e /src/Wallabag/CoreBundle/Tests | |
parent | f530f7f5e19eb611ba79856d3ca3b7aebd2af367 (diff) | |
download | wallabag-003fa77438b13ceb9ceda245d6ad257801453d27.tar.gz wallabag-003fa77438b13ceb9ceda245d6ad257801453d27.tar.zst wallabag-003fa77438b13ceb9ceda245d6ad257801453d27.zip |
Add tests for the StringToListTransformer class
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php b/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php new file mode 100644 index 00000000..d114e5f3 --- /dev/null +++ b/src/Wallabag/CoreBundle/Tests/Form/DataTransformer/StringToListTransformerTest.php | |||
@@ -0,0 +1,50 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Form\DataTransformer; | ||
4 | |||
5 | use Wallabag\CoreBundle\Form\DataTransformer\StringToListTransformer; | ||
6 | |||
7 | class StringToListTransformerTest extends \PHPUnit_Framework_TestCase | ||
8 | { | ||
9 | /** | ||
10 | * @dataProvider transformProvider | ||
11 | */ | ||
12 | public function testTransformWithValidData($inputData, $expectedResult) | ||
13 | { | ||
14 | $transformer = new StringToListTransformer(); | ||
15 | |||
16 | $this->assertSame($expectedResult, $transformer->transform($inputData)); | ||
17 | } | ||
18 | |||
19 | public function transformProvider() | ||
20 | { | ||
21 | return array( | ||
22 | array( null, '' ), | ||
23 | array( array(), '' ), | ||
24 | array( array('single value'), 'single value' ), | ||
25 | array( array('first value', 'second value'), 'first value,second value' ), | ||
26 | ); | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * @dataProvider reverseTransformProvider | ||
31 | */ | ||
32 | public function testReverseTransformWithValidData($inputData, $expectedResult) | ||
33 | { | ||
34 | $transformer = new StringToListTransformer(); | ||
35 | |||
36 | $this->assertSame($expectedResult, $transformer->reverseTransform($inputData)); | ||
37 | } | ||
38 | |||
39 | public function reverseTransformProvider() | ||
40 | { | ||
41 | return array( | ||
42 | array( null, null ), | ||
43 | array( '', array() ), | ||
44 | array( 'single value', array('single value') ), | ||
45 | array( 'first value,second value', array('first value', 'second value') ), | ||
46 | array( 'first value, second value', array('first value', 'second value') ), | ||
47 | array( 'first value, , second value', array('first value', 'second value') ), | ||
48 | ); | ||
49 | } | ||
50 | } | ||