diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-03 19:26:54 +0200 |
commit | 4f5b44bd3bd490309eb2ba7b44df4769816ba729 (patch) | |
tree | 6cefe170dfe0a5a361cb1e2d1fc4d580a3316d02 /vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php | |
parent | 2b840e0cfb63a453bea67a98541f3df9c273c5f5 (diff) | |
download | wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.gz wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.tar.zst wallabag-4f5b44bd3bd490309eb2ba7b44df4769816ba729.zip |
twig implementation
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php new file mode 100644 index 00000000..57297193 --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php | |||
@@ -0,0 +1,76 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; | ||
13 | |||
14 | use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; | ||
15 | |||
16 | use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer; | ||
17 | |||
18 | class ChoicesToValuesTransformerTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | protected $transformer; | ||
21 | |||
22 | protected function setUp() | ||
23 | { | ||
24 | $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B', 2 => 'C')); | ||
25 | $this->transformer = new ChoicesToValuesTransformer($list); | ||
26 | } | ||
27 | |||
28 | protected function tearDown() | ||
29 | { | ||
30 | $this->transformer = null; | ||
31 | } | ||
32 | |||
33 | public function testTransform() | ||
34 | { | ||
35 | // Value strategy in SimpleChoiceList is to copy and convert to string | ||
36 | $in = array(0, 1, 2); | ||
37 | $out = array('0', '1', '2'); | ||
38 | |||
39 | $this->assertSame($out, $this->transformer->transform($in)); | ||
40 | } | ||
41 | |||
42 | public function testTransformNull() | ||
43 | { | ||
44 | $this->assertSame(array(), $this->transformer->transform(null)); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
49 | */ | ||
50 | public function testTransformExpectsArray() | ||
51 | { | ||
52 | $this->transformer->transform('foobar'); | ||
53 | } | ||
54 | |||
55 | public function testReverseTransform() | ||
56 | { | ||
57 | // values are expected to be valid choices and stay the same | ||
58 | $in = array('0', '1', '2'); | ||
59 | $out = array(0, 1, 2); | ||
60 | |||
61 | $this->assertSame($out, $this->transformer->reverseTransform($in)); | ||
62 | } | ||
63 | |||
64 | public function testReverseTransformNull() | ||
65 | { | ||
66 | $this->assertSame(array(), $this->transformer->reverseTransform(null)); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException | ||
71 | */ | ||
72 | public function testReverseTransformExpectsArray() | ||
73 | { | ||
74 | $this->transformer->reverseTransform('foobar'); | ||
75 | } | ||
76 | } | ||