Ejemplo n.º 1
0
 /**
  * Test loadData
  *
  * @return void
  */
 public function testLoadData()
 {
     $this->scopeTreeMock->expects($this->any())->method('get')->willReturn(['scope' => ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 'scope_id' => null, 'scopes' => [['scope' => ScopeInterface::SCOPE_WEBSITE, 'scope_id' => 1, 'scopes' => [['scope' => ScopeInterface::SCOPE_GROUP, 'scope_id' => 1, 'scopes' => [['scope' => ScopeInterface::SCOPE_STORE, 'scope_id' => 1, 'scopes' => []]]]]]]]);
     $this->metadataProviderMock->expects($this->any())->method('get')->willReturn(['first_field' => ['path' => 'first/field/path', 'use_in_grid' => 0], 'second_field' => ['path' => 'second/field/path', 'use_in_grid' => true], 'third_field' => ['path' => 'third/field/path']]);
     $this->appConfigMock->expects($this->any())->method('getValue')->willReturnMap([['second/field/path', ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null, 'DefaultValue'], ['second/field/path', ScopeInterface::SCOPE_WEBSITE, 1, 'WebsiteValue'], ['second/field/path', ScopeInterface::SCOPE_STORE, 1, 'WebsiteValue']]);
     $this->valueProcessor->expects($this->atLeastOnce())->method('process')->withConsecutive(['DefaultValue', 'default', null, ['path' => 'second/field/path', 'use_in_grid' => 1]], ['WebsiteValue', 'website', 1, ['path' => 'second/field/path', 'use_in_grid' => 1]], ['WebsiteValue', 'store', 1, ['path' => 'second/field/path', 'use_in_grid' => 1]])->willReturnOnConsecutiveCalls('DefaultValue', 'WebsiteValue', 'WebsiteValue');
     $expectedResult = [new \Magento\Framework\DataObject(['store_website_id' => null, 'store_group_id' => null, 'store_id' => null, 'second_field' => 'DefaultValue']), new \Magento\Framework\DataObject(['store_website_id' => 1, 'store_group_id' => null, 'store_id' => null, 'second_field' => 'WebsiteValue']), new \Magento\Framework\DataObject(['store_website_id' => 1, 'store_group_id' => 1, 'store_id' => 1, 'second_field' => 'WebsiteValue'])];
     $this->assertEquals($expectedResult, $this->collection->getItems());
 }
Ejemplo n.º 2
0
 public function testCreateInSingleStoreMode()
 {
     $scope = 'default';
     $scopeId = 0;
     $data = ['header_default_title' => 'value'];
     $metadata = ['header_default_title' => ['path' => 'design/header/default_title', 'fieldset' => 'head'], 'head_default_description' => ['path' => 'design/head/default_description', 'fieldset' => 'head']];
     $this->scopeValidator->expects($this->once())->method('isValidScope')->with($scope, $scopeId)->willReturn(true);
     $this->storeManager->expects($this->once())->method('isSingleStoreMode')->willReturn(true);
     $this->storeManager->expects($this->once())->method('getWebsites')->willReturn([$this->website]);
     $this->website->expects($this->once())->method('getId')->willReturn(1);
     $this->designConfigFactory->expects($this->once())->method('create')->willReturn($this->designConfig);
     $this->designConfig->expects($this->once())->method('setScope')->willReturn('websites');
     $this->designConfig->expects($this->once())->method('setScopeId')->willReturn(1);
     $this->metadataProvider->expects($this->once())->method('get')->willReturn($metadata);
     $this->designConfigDataFactory->expects($this->exactly(2))->method('create')->willReturn($this->designConfigData);
     $this->designConfigData->expects($this->exactly(2))->method('setPath')->withConsecutive(['design/header/default_title'], ['design/head/default_description']);
     $this->designConfigData->expects($this->exactly(2))->method('setFieldConfig')->withConsecutive([['path' => 'design/header/default_title', 'fieldset' => 'head', 'field' => 'header_default_title']], [['path' => 'design/head/default_description', 'fieldset' => 'head', 'field' => 'head_default_description']]);
     $this->designConfigData->expects($this->once())->method('setValue')->with('value');
     $this->configExtensionFactory->expects($this->once())->method('create')->willReturn($this->designConfigExtension);
     $this->designConfigExtension->expects($this->once())->method('setDesignConfigData')->with([$this->designConfigData, $this->designConfigData]);
     $this->designConfig->expects($this->once())->method('setExtensionAttributes')->with($this->designConfigExtension);
     $this->assertSame($this->designConfig, $this->factory->create($scope, $scopeId, $data));
 }