/** * @param int $callNumber * @param string $oldValue * @dataProvider afterSaveDataProvider */ public function testAfterSave($callNumber, $oldValue) { $this->cacheTypeListMock->expects($this->exactly($callNumber))->method('invalidate'); $this->configMock->expects($this->any())->method('getValue')->willReturnMap([[Theme::XML_PATH_INVALID_CACHES, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null, ['block_html' => 1, 'layout' => 1, 'translate' => 1]], [null, \Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, $oldValue]]); $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); }
public function testAfterDelete() { $this->configMock->expects($this->any())->method('getValue')->willReturnMap([[Theme::XML_PATH_INVALID_CACHES, ScopeInterface::SCOPE_STORE, null, ['block_html' => 1, 'layout' => 1, 'translate' => 1]], [null, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, 'old_value']]); $this->cacheTypeListMock->expects($this->exactly(2))->method('invalidate'); $this->model->setValue('some_value'); $this->assertSame($this->model, $this->model->afterDelete()); }
/** * @dataProvider invalidateCacheDataProvider * @param bool $cacheState */ public function testExecute($cacheState) { $this->_configMock->expects($this->once())->method('isEnabled')->will($this->returnValue($cacheState)); if ($cacheState) { $this->_typeListMock->expects($this->once())->method('invalidate')->with($this->equalTo('full_page')); } $this->_model->execute($this->observerMock); }
public function testAfterExecuteInvalidate() { $subject = $this->getMockBuilder('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\AbstractAction')->disableOriginalConstructor()->getMockForAbstractClass(); $result = $this->getMockBuilder('Magento\\Catalog\\Model\\Indexer\\Category\\Product\\AbstractAction')->disableOriginalConstructor()->getMockForAbstractClass(); $this->config->expects($this->once())->method('isEnabled')->willReturn(true); $this->typeList->expects($this->once())->method('invalidate')->with('full_page'); $this->assertEquals($result, $this->execute->afterExecute($subject, $result)); }
/** * @dataProvider invalidateCacheDataProvider * @param bool $cacheState */ public function testExecuteNoChanged($cacheState) { $this->configMock->expects($this->once())->method('isEnabled')->will($this->returnValue($cacheState)); $this->typeListMock->expects($this->never())->method('invalidate'); if ($cacheState) { $this->objectMock->expects($this->once())->method('getIdentities')->will($this->returnValue([])); } $this->model->execute($this->observerMock); }
public function testAroundSave() { $subject = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Attribute')->disableOriginalConstructor()->getMock(); $attribute = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute')->disableOriginalConstructor()->getMock(); $self = $this; $proceed = function ($object) use($self, $attribute) { $self->assertEquals($object, $attribute); }; $this->config->expects($this->once())->method('isEnabled')->willReturn(true); $this->typeList->expects($this->once())->method('invalidate')->with('full_page'); $this->save->aroundSave($subject, $proceed, $attribute); }
public function testFinish() { $cacheTypeListArray = array('one', 'two'); $this->_cache->expects($this->once())->method('clean'); $this->_config->expects($this->once())->method('reinit'); $this->_cacheState->expects($this->once())->method('persist'); $this->_cacheState->expects($this->exactly(count($cacheTypeListArray)))->method('setEnabled'); $this->_cacheTypeList->expects($this->once())->method('getTypes')->will($this->returnValue($cacheTypeListArray)); $this->_appState->expects($this->once())->method('setInstallDate')->with($this->greaterThanOrEqual(date('r'))); $this->_installerConfig->expects($this->once())->method('replaceTmpInstallDate')->with($this->greaterThanOrEqual(date('r'))); $this->assertSame($this->_model, $this->_model->finish()); }
/** * @param int $callNumber * @param string $oldValue * @dataProvider afterSaveDataProvider */ public function testAfterSave($callNumber, $oldValue) { $this->cacheTypeListMock->expects($this->exactly($callNumber))->method('invalidate'); $this->configMock->expects($this->any())->method('getValue')->willReturn($oldValue); $this->model->setValue('some_value'); $this->assertInstanceOf(get_class($this->model), $this->model->afterSave()); }
public function testSetCurrencySymbolData() { $websiteId = 1; $groupId = 2; $currencies = 'USD,EUR'; $symbols = []; $value['options']['fields']['customsymbol']['inherit'] = 1; $this->prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $currencies); /** * @var \Magento\Config\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ $configMock = $this->getMock('Magento\\Config\\Model\\Config', ['setSection', 'setWebsite', 'setStore', 'setGroups', 'save'], [], '', false); $this->configFactoryMock->expects($this->any())->method('create')->willReturn($configMock); $configMock->expects($this->any())->method('setSection')->with(Currencysymbol::CONFIG_SECTION)->willReturnSelf(); $configMock->expects($this->any())->method('setWebsite')->with(null)->willReturnSelf(); $configMock->expects($this->any())->method('setStore')->with(null)->willReturnSelf(); $configMock->expects($this->any())->method('setGroups')->with($value)->willReturnSelf(); $this->coreConfigMock->expects($this->once())->method('reinit'); $this->cacheTypeListMock->expects($this->atLeastOnce())->method('invalidate'); $this->eventManagerMock->expects($this->atLeastOnce())->method('dispatch')->willReturnMap([['admin_system_config_changed_section_currency_before_reinit', null, null], ['admin_system_config_changed_section_currency', null, null]]); $this->assertInstanceOf('Magento\\CurrencySymbol\\Model\\System\\Currencysymbol', $this->model->setCurrencySymbolsData($symbols)); }
public function testGetAvailableTypes() { $types = [['id' => 'foo', 'status' => true], ['id' => 'bar', 'status' => false]]; $this->cacheTypeList->expects($this->once())->method('getTypes')->willReturn($types); $this->assertSame(['foo', 'bar'], $this->model->getAvailableTypes()); }
/** * @return void; */ public function testAfterDelete() { $this->cacheTypeListMock->expects($this->once())->method('invalidate'); $this->assertInstanceOf(get_class($this->model), $this->model->afterDelete()); }