/** * @param bool $fixtureResultOne * @param bool $fixtureResultTwo * @param bool $expectedResult * @dataProvider cleanModeMatchingAnyTagDataProvider */ public function testCleanModeMatchingAnyTag($fixtureResultOne, $fixtureResultTwo, $expectedResult) { $this->frontendMock->expects($this->at(0))->method('clean')->with(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['test_tag_one', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG])->will($this->returnValue($fixtureResultOne)); $this->frontendMock->expects($this->at(1))->method('clean')->with(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, ['test_tag_two', \Magento\Framework\App\Cache\Type\Config::CACHE_TAG])->will($this->returnValue($fixtureResultTwo)); $actualResult = $this->model->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, ['test_tag_one', 'test_tag_two']); $this->assertEquals($expectedResult, $actualResult); }
/** * @param $data * @param $result * @dataProvider dataProviderForTestGetData */ public function testGetData($data, $result) { $this->cache->expects($this->once())->method('load')->will($this->returnValue(serialize($data))); $this->expectsSetConfig('themeId'); $this->translate->loadData('frontend'); $this->assertEquals($result, $this->translate->getData()); }
public function testGenerateElementsWithCache() { $layoutCacheId = 'layout_cache_id'; /** @var \Magento\Framework\View\Layout\Element $xml */ $xml = simplexml_load_string('<layout/>', 'Magento\Framework\View\Layout\Element'); $this->model->setXml($xml); $themeMock = $this->getMockForAbstractClass('Magento\Framework\View\Design\ThemeInterface'); $this->themeResolverMock->expects($this->once()) ->method('get') ->willReturn($themeMock); $this->processorFactoryMock->expects($this->once()) ->method('create') ->with(['theme' => $themeMock]) ->willReturn($this->processorMock); $this->processorMock->expects($this->once()) ->method('getCacheId') ->willReturn($layoutCacheId); $readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context') ->disableOriginalConstructor() ->getMock(); $this->cacheMock->expects($this->once()) ->method('load') ->with('structure_' . $layoutCacheId) ->willReturn(serialize($readerContextMock)); $this->readerPoolMock->expects($this->never()) ->method('interpret'); $this->cacheMock->expects($this->never()) ->method('save'); $generatorContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context') ->disableOriginalConstructor() ->getMock(); $this->generatorContextFactoryMock->expects($this->once()) ->method('create') ->with(['structure' => $this->structureMock, 'layout' => $this->model]) ->willReturn($generatorContextMock); $this->generatorPoolMock->expects($this->once()) ->method('process') ->with($readerContextMock, $generatorContextMock) ->willReturn(true); $elements = [ 'name_1' => ['type' => '', 'parent' => null], 'name_2' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => null], 'name_3' => ['type' => '', 'parent' => 'parent'], 'name_4' => ['type' => \Magento\Framework\View\Layout\Element::TYPE_CONTAINER, 'parent' => 'parent'], ]; $this->structureMock->expects($this->once()) ->method('exportElements') ->willReturn($elements); $this->model->generateElements(); }
public function testPersist() { $cacheTypes = array('cache_type' => false); $model = $this->_buildModel($cacheTypes); $this->_resource->expects($this->once())->method('saveAllOptions')->with($cacheTypes); $this->_cacheFrontend->expects($this->once())->method('remove')->with(\Magento\Framework\App\Cache\State::CACHE_ID); $model->persist(); }
public function testClean() { $this->_cache->expects( $this->once() )->method( 'clean' )->with( \Zend_Cache::CLEANING_MODE_MATCHING_TAG, [\Magento\Framework\App\Config\ScopePool::CACHE_TAG] ); $this->_object->clean('testScope'); }