/** * @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']); }