public function testDelete() { $this->designConfig->expects($this->exactly(2))->method('getExtensionAttributes')->willReturn($this->designExtension); $this->designExtension->expects($this->once())->method('getDesignConfigData')->willReturn([$this->designConfigData]); $this->configStorage->expects($this->once())->method('delete')->with($this->designConfig); $this->reinitableConfig->expects($this->once())->method('reinit'); $this->indexerRegistry->expects($this->once())->method('get')->with(Config::DESIGN_CONFIG_GRID_INDEXER_ID)->willReturn($this->indexer); $this->indexer->expects($this->once())->method('reindexAll'); $this->assertSame($this->designConfig, $this->repository->delete($this->designConfig)); }
/** * @param string $scope * @param string $scopeId * @param string $showFallbackReset * @dataProvider dataProviderGetData */ public function testGetData($scope, $scopeId, $showFallbackReset) { $this->request->expects($this->exactly(2))->method('getParam')->willReturnMap([['scope', null, $scope], ['scope_id', null, $scopeId]]); $this->scopeFallbackResolver->expects($this->atLeastOnce())->method('getFallbackScope')->with($scope, $scopeId)->willReturn([$scope, $scopeId]); $this->storeManager->expects($this->once())->method('isSingleStoreMode')->willReturn(false); $this->designConfigRepository->expects($this->once())->method('getByScope')->with($scope, $scopeId)->willReturn($this->designConfig); $this->designConfig->expects($this->once())->method('getExtensionAttributes')->willReturn($this->designConfigExtension); $this->designConfigExtension->expects($this->once())->method('getDesignConfigData')->willReturn([$this->designConfigData]); $this->designConfigData->expects($this->atLeastOnce())->method('getFieldConfig')->willReturn(['field' => 'field', 'fieldset' => 'fieldset1']); $this->designConfigData->expects($this->once())->method('getValue')->willReturn('value'); $result = $this->model->getData(); $expected = ['fieldset1' => ['children' => ['field' => ['arguments' => ['data' => ['config' => ['default' => 'value', 'showFallbackReset' => $showFallbackReset]]]]]]]; $this->assertEquals($expected, $result); }
public function testGetDataWithNoItems() { $scope = 'websites'; $scopeId = 1; $this->request->expects($this->exactly(2))->method('getParam')->willReturnMap([['scope', null, $scope], ['scope_id', null, $scopeId]]); $this->designConfigRepository->expects($this->once())->method('getByScope')->with($scope, $scopeId)->willReturn($this->designConfig); $this->designConfig->expects($this->once())->method('getExtensionAttributes')->willReturn($this->designConfigExtension); $this->designConfigExtension->expects($this->once())->method('getDesignConfigData')->willReturn([$this->designConfigData]); $this->designConfigData->expects($this->once())->method('getFieldConfig')->willReturn(['field' => 'field']); $this->designConfigData->expects($this->once())->method('getValue')->willReturn('value'); $this->dataPersistor->expects($this->once())->method('get')->with('theme_design_config')->willReturn(['scope' => $scope, 'scope_id' => $scopeId]); $result = $this->model->getData(); $this->assertTrue(is_array($result)); $this->assertTrue(array_key_exists($scope, $result)); $this->assertTrue(is_array($result[$scope])); $this->assertTrue(array_key_exists('scope', $result[$scope])); $this->assertTrue(array_key_exists('scope_id', $result[$scope])); $this->assertEquals($scope, $result[$scope]['scope']); $this->assertEquals($scopeId, $result[$scope]['scope_id']); }
public function testDelete() { $scope = 'website'; $scopeId = 1; $backendModel = $this->getMockBuilder('Magento\\Framework\\App\\Config\\Value')->disableOriginalConstructor()->getMock(); $this->designConfig->expects($this->once())->method('getExtensionAttributes')->willReturn($this->designConfigExtension); $this->designConfigExtension->expects($this->once())->method('getDesignConfigData')->willReturn([$this->designConfigData]); $this->transactionFactoryMock->expects($this->once())->method('create')->willReturn($this->transactionMock); $this->designConfigData->expects($this->once())->method('getValue')->willReturn('value'); $this->designConfigData->expects($this->once())->method('getFieldConfig')->willReturn([]); $this->designConfig->expects($this->once())->method('getScope')->willReturn($scope); $this->designConfig->expects($this->once())->method('getScopeId')->willReturn($scopeId); $this->backendModelFactoryMock->expects($this->once())->method('create')->with(['value' => 'value', 'scope' => $scope, 'scopeId' => $scopeId, 'config' => []])->willReturn($backendModel); $this->transactionMock->expects($this->once())->method('addObject')->with($backendModel); $this->transactionMock->expects($this->once())->method('delete'); $this->model->delete($this->designConfig); }