Esempio 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());
 }
 /**
  * Load data
  *
  * @param bool $printQuery
  * @param bool $logQuery
  * @return \Magento\Theme\Model\ResourceModel\Design\Config\Scope\Collection
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function loadData($printQuery = false, $logQuery = false)
 {
     if (!$this->isLoaded()) {
         $default = $this->scopeTree->get();
         $this->prepareItemData();
         foreach ($default['scopes'] as $website) {
             $this->prepareItemData($website);
             foreach ($website['scopes'] as $group) {
                 foreach ($group['scopes'] as $store) {
                     $this->prepareItemData($website, $group, $store);
                 }
             }
         }
         $this->_setIsLoaded(true);
     }
     return $this;
 }