* * 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:----s6riNKncbjINkSloHUy81/UxmnNExR5Ac0hFNRzQasxbnwkCpi39qnY4xL0veHflsaBxu5/Ww5piFdvP//Jgg2XtCsHdOaTSg/12fpqkLhwJInQEZaZKuYImcPxuK6Wq/rbNJ7sKhntCKI5sZpC64HFdPTZMXrizlXfwfWN5wUthzsdpSftoYTrzQ5xiE1BhpcQaUhoeMsi8YQZ8+9QOkbWvC2PWZ/BQAxwiaH4XZGFGn1mMg2WtBRb4tt+tOyYfcxLFtPyXFuKneMFT8WPbNXYIiu9llBaayoqYqpkUzY4+UHpbIt/P/0lAlWQNBxnEUGuEQdhYy+HA5J0EklY5eCkbdHeOe5LCCaSOy6Bi/di0NWiZ8fjZrQ/1ldmuAupBM3xsFamiGytvjeTWBms866EedwNdja2EFZUDiSZYllpGfAhDxy8GrF6bbo/5hZzNTL6rjAe5a6Da4hM1jEG3uJiYL6fa0+mIJdxzSqgNfU7YDMXty4u83ZGKEyQA4LX6Q8PzeNsb+yj+QXwsS0sQGpPOclRVaNF0/jy4ZHjdS5GgryAxSZlxWIsFV5iMYqb15ZZ9wDnerPqlZpybWW30Xh+9XWVxBahISogZ3Wh/D/rLESNf99xBkpnLCaGpgD1Nkj12Q+FCAVM1YfdE+efOFZA8a5e1XMR4mIgnfkv/QAY=----ATTACHMENT:----MjI0NTI4MDU4OTA0NzgyMiA1NDY2Njg1NjU5ODI4NDMzIDkwNTA2OTY5MDE5MDgwODM=