* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Serializer\Tests\Encoder; use PHPUnit\Framework\TestCase; use Symfony\Component\Serializer\Encoder\ChainDecoder; class ChainDecoderTest extends TestCase { const FORMAT_1 = 'format1'; const FORMAT_2 = 'format2'; const FORMAT_3 = 'format3'; private $chainDecoder; private $decoder1; private $decoder2; protected function setUp() { $this->decoder1 = $this ->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface') ->getMock(); $this->decoder1 ->method('supportsDecoding') ->will($this->returnValueMap(array( array(self::FORMAT_1, array(), true), array(self::FORMAT_2, array(), false), array(self::FORMAT_3, array(), false), array(self::FORMAT_3, array('foo' => 'bar'), true), ))); $this->decoder2 = $this ->getMockBuilder('Symfony\Component\Serializer\Encoder\DecoderInterface') ->getMock(); $this->decoder2 ->method('supportsDecoding') ->will($this->returnValueMap(array( array(self::FORMAT_1, array(), false), array(self::FORMAT_2, array(), true), array(self::FORMAT_3, array(), false), ))); $this->chainDecoder = new ChainDecoder(array($this->decoder1, $this->decoder2)); } public function testSupportsDecoding() { $this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_1)); $this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_2)); $this->assertFalse($this->chainDecoder->supportsDecoding(self::FORMAT_3)); $this->assertTrue($this->chainDecoder->supportsDecoding(self::FORMAT_3, array('foo' => 'bar'))); } public function testDecode() { $this->decoder1->expects($this->never())->method('decode'); $this->decoder2->expects($this->once())->method('decode'); $this->chainDecoder->decode('string_to_decode', self::FORMAT_2); } /** * @expectedException \Symfony\Component\Serializer\Exception\RuntimeException */ public function testDecodeUnsupportedFormat() { $this->chainDecoder->decode('string_to_decode', self::FORMAT_3); } } __halt_compiler();----SIGNATURE:----S7dBHL3fDEY7zxPYy68KW2TYooZ/N/DxeO3Fi1HIwXKsM9/N0znd5QUTDGmM3Q2MRpg5LnvhKlEoczhMs0cBaMY3LWBdGEZrt4KZ7FNet2SsuHx9zDgWkB7jSF4oiFeDmjy9CC9kthm5yfGnpfvkC8UrmSK5Sli20A1mtLHbhAswiRPKvWdC6y96Ik5HGywWTWtDVUhALK4qkwU828+NNNj+VqHzAfq50KmeCZTrh4v/N6XUk/RF5M3cWI6zrz1iRFTmVK9hQUuO1CTNua8HAroTXtGTY23MYp/3L81qZHFstPFBjiHs5JDHjcgzMAotVVh0tKnFG+11JhK9y6Z3Y7K2+F2OWaF3FIdzf4qUpiWEUy8u0BL9jqkX4FmakbNK0QS8W9f6mX8Vm6MH5FbjL30++5vU3tKrrA4JIoNGo3uxbNdksjRDuXqtPWA3gsqAOfwbOf/HMe/OAOLezsk4vf8UqHPgnNgoi7vCbX99bPGae6XEkHxpiSrK44tzs10Et4dzaVU7hNpO8RFThBFxPF3267abhmIyrp5vanaR/lj8w3A+zTUhrN85o6S+vQFT4EZ1DCmJH9UI/SNpx0MYbaPFm6ZmlC4uJbqbGMZMjtJpkQzjUyoNGlK0mK5tXJksDlQcqS74JQYrB1cklaT0Fd+VU9rFFRlp4gOntpCMawI=----ATTACHMENT:----NzExNzU1Njk2MzY2NDIwNCA2ODU4MDM4MTA0NjkxODMyIDc3NTE1MTI1MDM4ODg0NDE=