4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer
;
14 use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer
;
16 class ValueToDuplicatesTransformerTest
extends \PHPUnit_Framework_TestCase
20 protected function setUp()
22 $this->transformer
= new ValueToDuplicatesTransformer(array('a', 'b', 'c'));
25 protected function tearDown()
27 $this->transformer
= null;
30 public function testTransform()
38 $this->assertSame($output, $this->transformer
->transform('Foo'));
41 public function testTransformEmpty()
49 $this->assertSame($output, $this->transformer
->transform(null));
52 public function testReverseTransform()
60 $this->assertSame('Foo', $this->transformer
->reverseTransform($input));
63 public function testReverseTransformCompletelyEmpty()
71 $this->assertNull($this->transformer
->reverseTransform($input));
74 public function testReverseTransformCompletelyNull()
82 $this->assertNull($this->transformer
->reverseTransform($input));
86 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
88 public function testReverseTransformPartiallyNull()
96 $this->transformer
->reverseTransform($input);
100 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
102 public function testReverseTransformDifferences()
110 $this->transformer
->reverseTransform($input);
114 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
116 public function testReverseTransformRequiresArray()
118 $this->transformer
->reverseTransform('12345');