ApiPlatform\Core\Tests\Metadata\Property\Factory\CachedPropertyMetadataFactoryTest::testCreateWithItemHit PHP Method

testCreateWithItemHit() public method

    public function testCreateWithItemHit()
    {
        $cacheItem = $this->prophesize(CacheItemInterface::class);
        $cacheItem->isHit()->willReturn(true)->shouldBeCalled();
        $cacheItem->get()->willReturn(new PropertyMetadata(null, 'A dummy', true, true, null, null, false, false))->shouldBeCalled();
        $cacheItemPool = $this->prophesize(CacheItemPoolInterface::class);
        $cacheItemPool->getItem($this->generateCacheKey())->willReturn($cacheItem->reveal())->shouldBeCalled();
        $decoratedPropertyMetadataFactory = $this->prophesize(PropertyMetadataFactoryInterface::class);
        $cachedPropertyMetadataFactory = new CachedPropertyMetadataFactory($cacheItemPool->reveal(), $decoratedPropertyMetadataFactory->reveal());
        $resultedPropertyMetadata = $cachedPropertyMetadataFactory->create(Dummy::class, 'dummy');
        $this->assertInstanceOf(PropertyMetadata::class, $resultedPropertyMetadata);
        $this->assertEquals(new PropertyMetadata(null, 'A dummy', true, true, null, null, false, false), $resultedPropertyMetadata);
    }