/** * @test */ public function process() { $finderMock = $this->getMock('Semaio\\ConfigImportExport\\Model\\File\\Finder', ['find']); $finderMock->expects($this->once())->method('find')->willReturn(['abc.yaml']); $parseResult = ['test/config/custom_field_one' => ['default' => [0 => 'ABC']]]; $readerMock = $this->getMock('Semaio\\ConfigImportExport\\Model\\File\\Reader\\YamlReader', ['parse']); $readerMock->expects($this->once())->method('parse')->willReturn($parseResult); $this->scopeValidatorMock->expects($this->once())->method('validate')->willReturn(true); $this->configWriterMock->expects($this->once())->method('save'); $processor = new ImportProcessor($this->configWriterMock, $this->scopeValidatorMock, $this->scopeConverterMock); $processor->setOutput($this->outputMock); $processor->setFinder($finderMock); $processor->setReader($readerMock); $processor->process(); }
/** * @param string $path * @param array $config * @return array */ public function transformConfigToScopeConfig($path, array $config) { $return = []; foreach ($config as $scope => $scopeIdValue) { if (!$scopeIdValue) { continue; } foreach ($scopeIdValue as $scopeId => $value) { if (!$this->scopeValidator->validate($scope, $scopeId)) { $errorMsg = sprintf('<error>ERROR: Invalid scopeId "%s" for scope "%s" (%s => %s)</error>', $scopeId, $scope, $path, $value); $this->getOutput()->writeln($errorMsg); continue; } $return[] = ['value' => $value, 'scope' => $scope, 'scope_id' => $scopeId]; } } return $return; }