public function testPrepareDataSource()
 {
     $dataSource = ['data' => ['items' => [['stores' => [1]]]]];
     $expectedVisibility = "Test Website<br/>&nbsp;&nbsp;&nbsp;Test group<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Test store<br/>";
     $expectedDataSource = ['data' => ['items' => [['stores' => [1], 'visibility' => $expectedVisibility]]]];
     $this->storeMock->expects($this->once())->method('getStoresStructure')->willReturn([['label' => 'Test Website', 'children' => [['label' => 'Test group', 'children' => [['label' => 'Test store']]]]]]);
     $this->assertEquals($expectedDataSource, $this->getModel()->prepareDataSource($dataSource));
 }
Exemple #2
0
 /**
  * @dataProvider prepareDataSourceDataProvider
  */
 public function testPrepareDataSource($dataSource, $expectedResult)
 {
     $website = 'website';
     $group = 'group';
     $store = 'store';
     $storeStructure = [1 => ['value' => 1, 'label' => $website, 'children' => [1 => ['value' => 1, 'label' => $group, 'children' => [1 => ['value' => 1, 'label' => $store]]]]]];
     $this->escaperMock->expects($this->any())->method('escapeHtml')->willReturnMap([[$group, null, $group], [$store, null, $store]]);
     $this->systemStoreMock->expects($this->any())->method('getStoresStructure')->willReturn($storeStructure);
     $this->assertEquals($this->model->prepareDataSource($dataSource), $expectedResult);
 }
 /**
  * Prepare mocks for getCurrencySymbolsData
  *
  * @param int $websiteId
  * @param int $groupId
  * @param string $currencies
  */
 protected function prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $currencies)
 {
     /**
      * @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
      */
     $websiteMock = $this->getMock('Magento\\Store\\Model\\Website', ['getId', 'getConfig'], [], '', false);
     /**
      * @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
      */
     $groupMock = $this->getMock('Magento\\Store\\Model\\Group', ['getId', 'getWebsiteId'], [], '', false);
     /**
      * @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
      */
     $storeMock = $this->getMock('Magento\\Store\\Model\\Store', ['getGroupId'], [], '', false);
     $this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn([$websiteMock]);
     $this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn([$groupMock]);
     $this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn([$storeMock]);
     $websiteMock->expects($this->any())->method('getId')->willReturn($websiteId);
     $groupMock->expects($this->any())->method('getWebsiteId')->willReturn($websiteId);
     $groupMock->expects($this->any())->method('getId')->willReturn($groupId);
     $storeMock->expects($this->any())->method('getGroupId')->willReturn($groupId);
     $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturnMap([[CurrencySymbol::XML_PATH_CUSTOM_CURRENCY_SYMBOL, ScopeInterface::SCOPE_STORE, null, ''], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, $storeMock, $currencies], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, null, $currencies], [CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, $storeMock, $currencies]]);
     $websiteMock->expects($this->any())->method('getConfig')->with(CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES)->willReturn($currencies);
     $this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en');
 }
 public function testToHtmlWithoutRatingData()
 {
     $this->registry->expects($this->any())->method('registry')->will($this->returnValue(false));
     $this->systemStore->expects($this->any())->method('getStoreCollection')->will($this->returnValue(['0' => $this->store]));
     $this->formFactory->expects($this->any())->method('create')->will($this->returnValue($this->form));
     $this->viewFileSystem->expects($this->any())->method('getTemplateFileName')->will($this->returnValue('template_file_name.html'));
     $this->fileSystem->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->directoryReadInterface));
     $this->block->toHtml();
 }
Exemple #5
0
 public function testToOptionArray()
 {
     $websiteCollection = [$this->websiteMock];
     $groupCollection = [$this->groupMock];
     $storeCollection = [$this->storeMock];
     $expectedOptions = [['label' => __('All Store Views'), 'value' => '0'], ['label' => 'Main Website', 'value' => [['label' => '    Main Website Store', 'value' => [['label' => '        Default Store View', 'value' => '1']]]]]];
     $this->systemStoreMock->expects($this->once())->method('getWebsiteCollection')->willReturn($websiteCollection);
     $this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn($groupCollection);
     $this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn($storeCollection);
     $this->websiteMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
     $this->websiteMock->expects($this->any())->method('getName')->willReturn('Main Website');
     $this->groupMock->expects($this->atLeastOnce())->method('getWebsiteId')->willReturn('1');
     $this->groupMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
     $this->groupMock->expects($this->atLeastOnce())->method('getName')->willReturn('Main Website Store');
     $this->storeMock->expects($this->atLeastOnce())->method('getGroupId')->willReturn('1');
     $this->storeMock->expects($this->atLeastOnce())->method('getName')->willReturn('Default Store View');
     $this->storeMock->expects($this->atLeastOnce())->method('getId')->willReturn('1');
     $this->escaperMock->expects($this->atLeastOnce())->method('escapeHtml')->willReturnMap([['Default Store View', null, 'Default Store View'], ['Main Website Store', null, 'Main Website Store'], ['Main Website', null, 'Main Website']]);
     $this->assertEquals($expectedOptions, $this->options->toOptionArray());
 }
 /**
  * Mock website options
  *
  * @return array
  */
 protected function mockOptions()
 {
     $options = [['value' => 'value1', 'label' => 'label1'], ['value' => 'value2', 'label' => 'label2']];
     $this->storeMock->expects($this->once())->method('getWebsiteValuesForForm')->with(false, false)->willReturn($options);
     return $options;
 }