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\ArrayToPartsTransformer
;
16 class ArrayToPartsTransformerTest
extends \PHPUnit_Framework_TestCase
20 protected function setUp()
22 $this->transformer
= new ArrayToPartsTransformer(array(
23 'first' => array('a', 'b', 'c'),
24 'second' => array('d', 'e', 'f'),
28 protected function tearDown()
30 $this->transformer
= null;
33 public function testTransform()
57 $this->assertSame($output, $this->transformer
->transform($input));
60 public function testTransformEmpty()
67 $this->assertSame($output, $this->transformer
->transform(null));
71 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
73 public function testTransformRequiresArray()
75 $this->transformer
->transform('12345');
78 public function testReverseTransform()
102 $this->assertSame($output, $this->transformer
->reverseTransform($input));
105 public function testReverseTransformCompletelyEmpty()
112 $this->assertNull($this->transformer
->reverseTransform($input));
115 public function testReverseTransformCompletelyNull()
122 $this->assertNull($this->transformer
->reverseTransform($input));
126 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
128 public function testReverseTransformPartiallyNull()
139 $this->transformer
->reverseTransform($input);
143 * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
145 public function testReverseTransformRequiresArray()
147 $this->transformer
->reverseTransform('12345');