]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
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\DataTransformer\DataTransformerChain; | |
15 | ||
16 | class DataTransformerChainTest extends \PHPUnit_Framework_TestCase | |
17 | { | |
18 | public function testTransform() | |
19 | { | |
20 | $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | |
21 | $transformer1->expects($this->once()) | |
22 | ->method('transform') | |
23 | ->with($this->identicalTo('foo')) | |
24 | ->will($this->returnValue('bar')); | |
25 | $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | |
26 | $transformer2->expects($this->once()) | |
27 | ->method('transform') | |
28 | ->with($this->identicalTo('bar')) | |
29 | ->will($this->returnValue('baz')); | |
30 | ||
31 | $chain = new DataTransformerChain(array($transformer1, $transformer2)); | |
32 | ||
33 | $this->assertEquals('baz', $chain->transform('foo')); | |
34 | } | |
35 | ||
36 | public function testReverseTransform() | |
37 | { | |
38 | $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | |
39 | $transformer2->expects($this->once()) | |
40 | ->method('reverseTransform') | |
41 | ->with($this->identicalTo('foo')) | |
42 | ->will($this->returnValue('bar')); | |
43 | $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); | |
44 | $transformer1->expects($this->once()) | |
45 | ->method('reverseTransform') | |
46 | ->with($this->identicalTo('bar')) | |
47 | ->will($this->returnValue('baz')); | |
48 | ||
49 | $chain = new DataTransformerChain(array($transformer1, $transformer2)); | |
50 | ||
51 | $this->assertEquals('baz', $chain->reverseTransform('foo')); | |
52 | } | |
53 | } |