public function testReset() { $cacheid = 'test'; $this->cache->expects($this->once())->method('load')->will($this->returnValue(serialize([]))); $this->cache->expects($this->once())->method('remove')->with($cacheid); $config = new \Magento\Framework\Config\Data($this->reader, $this->cache, $cacheid); $config->reset(); }
public function testConstructorWithoutCache() { $this->cache->expects($this->once())->method('test')->with($this->cacheId)->will($this->returnValue(false)); $this->cache->expects($this->once())->method('load')->with($this->cacheId)->will($this->returnValue(false)); $this->reader->expects($this->once())->method('read')->will($this->returnValue($this->indexers)); $stateExistent = $this->getMock('Magento\\Indexer\\Model\\Indexer\\State', ['getIndexerId', '__wakeup', 'delete'], [], '', false); $stateExistent->expects($this->once())->method('getIndexerId')->will($this->returnValue('indexer1')); $stateExistent->expects($this->never())->method('delete'); $stateNonexistent = $this->getMock('Magento\\Indexer\\Model\\Indexer\\State', ['getIndexerId', '__wakeup', 'delete'], [], '', false); $stateNonexistent->expects($this->once())->method('getIndexerId')->will($this->returnValue('indexer2')); $stateNonexistent->expects($this->once())->method('delete'); $states = [$stateExistent, $stateNonexistent]; $this->stateCollection->expects($this->once())->method('getItems')->will($this->returnValue($states)); $this->model = new \Magento\Indexer\Model\Config\Data($this->reader, $this->cache, $this->stateCollection, $this->cacheId); }
public function testConstructorWithoutCache() { $this->cache->expects($this->once())->method('test')->with($this->cacheId)->will($this->returnValue(false)); $this->cache->expects($this->once())->method('load')->with($this->cacheId)->will($this->returnValue(false)); $this->reader->expects($this->once())->method('read')->will($this->returnValue($this->views)); $stateExistent = $this->getMock('Magento\\Framework\\Mview\\Indexer\\State', array('getViewId', '__wakeup', 'delete'), array(), '', false); $stateExistent->expects($this->once())->method('getViewId')->will($this->returnValue('view1')); $stateExistent->expects($this->never())->method('delete'); $stateNonexistent = $this->getMock('Magento\\Framework\\Mview\\Indexer\\State', array('getViewId', '__wakeup', 'delete'), array(), '', false); $stateNonexistent->expects($this->once())->method('getViewId')->will($this->returnValue('view2')); $stateNonexistent->expects($this->once())->method('delete'); $states = array($stateExistent, $stateNonexistent); $this->stateCollection->expects($this->once())->method('getItems')->will($this->returnValue($states)); $this->model = new \Magento\Framework\Mview\Config\Data($this->reader, $this->cache, $this->stateCollection, $this->cacheId); }
/** * @dataProvider getComponentData() */ public function testPrepareGetData($componentName, $componentData, $isCached, $readerData, $expectedResult) { $this->readerFactory->expects($this->any())->method('create')->with(['fileCollector' => $this->aggregatedFileCollector, 'domMerger' => $this->domMerger])->willReturn($this->uiReader); $this->aggregatedFileCollectorFactory->expects($this->any())->method('create')->willReturn($this->aggregatedFileCollector); $this->argumentInterpreter->expects($this->any())->method('evaluate')->willReturnCallback(function ($argument) { return ['argument' => $argument['value']]; }); $this->arrayObjectFactory->expects($this->any())->method('create')->willReturn($componentData); $this->cacheConfig->expects($this->any())->method('load')->with(Manager::CACHE_ID . '_' . $componentName)->willReturn($isCached); $this->uiReader->expects($this->any())->method('read')->willReturn($readerData); $this->assertEquals($expectedResult, $this->manager->prepareData($componentName)->getData($componentName)); }
public function testClean() { $this->cacheConfig->expects($this->once())->method('remove')->with($this->cacheKey); $this->model->clean(); }