* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Serializer\Tests\Mapping\Factory; use PHPUnit\Framework\TestCase; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Serializer\Mapping\ClassMetadata; use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; use Symfony\Component\Serializer\Tests\Fixtures\Dummy; /** * @author Kévin Dunglas */ class CacheMetadataFactoryTest extends TestCase { public function testGetMetadataFor() { $metadata = new ClassMetadata(Dummy::class); $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); $decorated ->expects($this->once()) ->method('getMetadataFor') ->will($this->returnValue($metadata)) ; $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); $this->assertEquals($metadata, $factory->getMetadataFor(Dummy::class)); // The second call should retrieve the value from the cache $this->assertEquals($metadata, $factory->getMetadataFor(Dummy::class)); } public function testHasMetadataFor() { $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); $decorated ->expects($this->once()) ->method('hasMetadataFor') ->will($this->returnValue(true)) ; $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); $this->assertTrue($factory->hasMetadataFor(Dummy::class)); } /** * @expectedException \Symfony\Component\Serializer\Exception\InvalidArgumentException */ public function testInvalidClassThrowsException() { $decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock(); $factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter()); $factory->getMetadataFor('Not\Exist'); } } __halt_compiler();----SIGNATURE:----GIlRxSNHIpYkZZTcTVCQaN8pyGoDJlncb/7GUZHfogHgdtMNMOvpli4yNis/ur/jZfY79XMzILePNu+8zSZnwoOkLwnpPJXyHAem5UtZFH/OXzdveU+5KyiSGOhjeekwss+3zUAKpk9W6qso0hMyutf9M2az60wQuZBGKHW1jTmGNWcbI3ieLGACKOydsaZQSVet14jshy2ppyHMcgq2AiViu54iH4UFyvrgGkCtTYPWV1AAuIo3V75xQdrCwEQkdbvIkta0eKm5yXvVqWufliW5+tb9SmgxZ385zKOx3znfR6UGNF8ubDMu0yiZcNf8m4YEu/ZwdKnR/lv/lu4IKiPoNxxpquaQnGBnDvpu76nuOUG53w5ZvI81SibbQTbzRuIshH10rlRL4JFPvm7uVLzo/yem02nEri/X7Qf1xKKy0WQPzbmAZcL30UyBJeks1ikot1q7mWCp3Hp9Kfypi68lIu9qKopanVkH7hmmurRPawq21wmDOnUWF2WDNS+/R4cSkld+uSyHnbysSL0RhnAm09UJOSo9pd4pM4RY0khB6VfJBo9KcznrzpXtR8BavviSRYEq0SlGdAaFGOXjlCybceKL0k4mknQffURqAgYMEzd/j5RPbC9xW8RsZJM34qtXt3GyCAVtQsqe29elImjOeakQCD8i4M9QkBV+EcI=----ATTACHMENT:----OTA0ODQ2NDA5NDQ3OTYyNCA4MjY1OTE5Mzc0NjA5MTI1IDM1MDYyMjc1MjcyNDU3MjI=