/** * @param string|null $fixtureSegment * @param string $inputCacheType * @param string $expectedFrontendId * * @dataProvider getDataProvider */ public function testGet($fixtureSegment, $inputCacheType, $expectedFrontendId) { $this->_deploymentConfig->expects($this->once())->method('getSegment')->with(\Magento\Framework\App\DeploymentConfig\CacheConfig::CONFIG_KEY)->will($this->returnValue($fixtureSegment)); $cacheFrontend = $this->getMock('Magento\\Framework\\Cache\\FrontendInterface'); $this->_cachePool->expects($this->once())->method('get')->with($expectedFrontendId)->will($this->returnValue($cacheFrontend)); $accessProxy = $this->getMock('Magento\\Framework\\App\\Cache\\Type\\AccessProxy', [], [], '', false); $this->_objectManager->expects($this->once())->method('create')->with('Magento\\Framework\\App\\Cache\\Type\\AccessProxy', $this->identicalTo(['frontend' => $cacheFrontend, 'identifier' => $inputCacheType]))->will($this->returnValue($accessProxy)); $this->assertSame($accessProxy, $this->_model->get($inputCacheType)); // Result has to be cached in memory $this->assertSame($accessProxy, $this->_model->get($inputCacheType)); }
/** * @param string|null $fixtureFrontendId * @param string $inputCacheType * @param string $expectedFrontendId * * @dataProvider getDataProvider */ public function testGet($fixtureFrontendId, $inputCacheType, $expectedFrontendId) { $this->_arguments->expects($this->once())->method('getCacheTypeFrontendId')->with($inputCacheType)->will($this->returnValue($fixtureFrontendId)); $cacheFrontend = $this->getMock('Magento\\Framework\\Cache\\FrontendInterface'); $this->_cachePool->expects($this->once())->method('get')->with($expectedFrontendId)->will($this->returnValue($cacheFrontend)); $accessProxy = $this->getMock('Magento\\Framework\\App\\Cache\\Type\\AccessProxy', array(), array(), '', false); $this->_objectManager->expects($this->once())->method('create')->with('Magento\\Framework\\App\\Cache\\Type\\AccessProxy', $this->identicalTo(array('frontend' => $cacheFrontend, 'identifier' => $inputCacheType)))->will($this->returnValue($accessProxy)); $this->assertSame($accessProxy, $this->_model->get($inputCacheType)); // Result has to be cached in memory $this->assertSame($accessProxy, $this->_model->get($inputCacheType)); }