Exemplo n.º 1
0
 protected function setUp()
 {
     $this->_helper = $this->getMock('Magento\\Catalog\\Helper\\Data', array('isPriceGlobal'), array(), '', false);
     $this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
     $loggerMock = $this->getMock('Magento\\Framework\\Logger', array(), array(), '', false);
     $currencyFactoryMock = $this->getMock('Magento\\Directory\\Model\\CurrencyFactory', array(), array(), '', false);
     $storeManagerMock = $this->getMock('Magento\\Framework\\StoreManagerInterface', array(), array(), '', false);
     $productTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type', array(), array(), '', false);
     $configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $this->_model = $this->getMockForAbstractClass('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Groupprice\\AbstractGroupprice', array('logger' => $loggerMock, 'currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, 'catalogData' => $this->_helper, 'config' => $configMock, 'catalogProductType' => $productTypeMock));
     $resource = $this->getMock('StdClass', array('getMainTable'));
     $resource->expects($this->any())->method('getMainTable')->will($this->returnValue('table'));
     $this->_model->expects($this->any())->method('_getResource')->will($this->returnValue($resource));
 }
Exemplo n.º 2
0
 /**
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function testGetSelectionsByIds()
 {
     $selectionIds = [1, 2, 3];
     $usedSelectionsIds = [4, 5, 6];
     $storeId = 2;
     $websiteId = 1;
     $storeFilter = 'store_filter';
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $usedSelectionsMock = $this->getMockBuilder('Magento\\Bundle\\Model\\Resource\\Selection\\Collection')->setMethods(['addAttributeToSelect', 'setFlag', 'addStoreFilter', 'setStoreId', 'setPositionOrder', 'addFilterByRequiredOptions', 'setSelectionIdsFilter', 'joinPrices'])->disableOriginalConstructor()->getMock();
     $productGetMap = [['_cache_instance_used_selections', null, null], ['_cache_instance_used_selections_ids', null, $usedSelectionsIds], ['_cache_instance_store_filter', null, $storeFilter]];
     $productMock->expects($this->any())->method('getData')->will($this->returnValueMap($productGetMap));
     $productSetMap = [['_cache_instance_used_selections', $usedSelectionsMock, $productMock], ['_cache_instance_used_selections_ids', $selectionIds, $productMock]];
     $productMock->expects($this->any())->method('setData')->will($this->returnValueMap($productSetMap));
     $productMock->expects($this->once())->method('getStoreId')->will($this->returnValue($storeId));
     $storeMock = $this->getMockBuilder('Magento\\Store\\Model\\Store')->setMethods(['getWebsiteId', '__wakeup'])->disableOriginalConstructor()->getMock();
     $this->storeManager->expects($this->once())->method('getStore')->with($storeId)->will($this->returnValue($storeMock));
     $storeMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue($websiteId));
     $this->bundleCollection->expects($this->once())->method('create')->will($this->returnValue($usedSelectionsMock));
     $usedSelectionsMock->expects($this->once())->method('addAttributeToSelect')->with('*')->will($this->returnSelf());
     $flagMap = [['require_stock_items', true, $usedSelectionsMock], ['product_children', true, $usedSelectionsMock]];
     $usedSelectionsMock->expects($this->any())->method('setFlag')->will($this->returnValueMap($flagMap));
     $usedSelectionsMock->expects($this->once())->method('addStoreFilter')->with($storeFilter)->will($this->returnSelf());
     $usedSelectionsMock->expects($this->once())->method('setStoreId')->with($storeId)->will($this->returnSelf());
     $usedSelectionsMock->expects($this->once())->method('setPositionOrder')->will($this->returnSelf());
     $usedSelectionsMock->expects($this->once())->method('addFilterByRequiredOptions')->will($this->returnSelf());
     $usedSelectionsMock->expects($this->once())->method('setSelectionIdsFilter')->with($selectionIds)->will($this->returnSelf());
     $usedSelectionsMock->expects($this->once())->method('joinPrices')->with($websiteId)->will($this->returnSelf());
     $this->catalogData->expects($this->once())->method('isPriceGlobal')->will($this->returnValue(false));
     $this->model->getSelectionsByIds($selectionIds, $productMock);
 }
Exemplo n.º 3
0
 protected function setUp()
 {
     $this->_helper = $this->getMock('Magento\\Catalog\\Helper\\Data', ['isPriceGlobal'], [], '', false);
     $this->_helper->expects($this->any())->method('isPriceGlobal')->will($this->returnValue(true));
     $currencyFactoryMock = $this->getMock('Magento\\Directory\\Model\\CurrencyFactory', ['create'], [], '', false);
     $storeManagerMock = $this->getMock('Magento\\Store\\Model\\StoreManagerInterface', [], [], '', false);
     $productTypeMock = $this->getMock('Magento\\Catalog\\Model\\Product\\Type', [], [], '', false);
     $configMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface');
     $localeFormatMock = $this->getMock('\\Magento\\Framework\\Locale\\FormatInterface', [], [], '', false);
     $groupManagement = $this->getMock('Magento\\Customer\\Api\\GroupManagementInterface', [], [], '', false);
     $metadataPool = $this->getMock('Magento\\Framework\\Model\\Entity\\MetadataPool', [], [], '', false);
     $this->_model = $this->getMockForAbstractClass('Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\GroupPrice\\AbstractGroupPrice', ['currencyFactory' => $currencyFactoryMock, 'storeManager' => $storeManagerMock, 'catalogData' => $this->_helper, 'config' => $configMock, 'localeFormat' => $localeFormatMock, 'catalogProductType' => $productTypeMock, 'groupManagement' => $groupManagement, 'metadataPool' => $metadataPool]);
     $resource = $this->getMock('StdClass', ['getMainTable']);
     $resource->expects($this->any())->method('getMainTable')->will($this->returnValue('table'));
     $this->_model->expects($this->any())->method('_getResource')->will($this->returnValue($resource));
 }
Exemplo n.º 4
0
 public function testSavePrices()
 {
     $rowSet = [0 => ['value_id' => '1', 'product_super_attribute_id' => '1', 'value_index' => '12', 'is_percent' => '0', 'pricing_value' => '3.0000', 'website_id' => '0'], 1 => ['value_id' => '2', 'product_super_attribute_id' => '1', 'value_index' => '13', 'is_percent' => '0', 'pricing_value' => '8.0000', 'website_id' => '0']];
     $values = [12 => ['value_index' => '12', 'pricing_value' => '', 'is_percent' => '0', 'include' => '1'], 13 => ['value_index' => '13', 'pricing_value' => '5', 'is_percent' => '0', 'include' => '1'], 14 => ['value_index' => '14', 'pricing_value' => '3', 'is_percent' => '0', 'include' => '1']];
     $attribute = $this->getMockBuilder('Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable\\Attribute')->setMethods(['getValues', 'getId'])->disableOriginalConstructor()->getMock();
     $adapterMock = $this->getMockBuilder('Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->getMock();
     $selectMock = $this->getMockBuilder('Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->once())->method('getConnection')->with('core_write')->willReturn($adapterMock);
     $this->catalogData->expects($this->any())->method('isPriceGlobal')->willReturn(1);
     $attribute->expects($this->once())->method('getValues')->willReturn($values);
     $adapterMock->expects($this->once())->method('select')->willReturn($selectMock);
     $selectMock->expects($this->once())->method('from')->with(null)->will($this->returnSelf());
     $selectMock->expects($this->at(1))->method('where')->with('product_super_attribute_id = :product_super_attribute_id')->will($this->returnSelf());
     $selectMock->expects($this->at(2))->method('where')->with('website_id = :website_id')->will($this->returnSelf());
     $attribute->expects($this->any())->method('getId')->willReturn(1);
     $adapterMock->expects($this->once())->method('fetchAll')->with($selectMock, ['product_super_attribute_id' => 1, 'website_id' => 0])->willReturn($rowSet);
     $this->assertEquals($this->model, $this->model->savePrices($attribute));
 }
Exemplo n.º 5
0
 /**
  * Additional function to break up mocks initialization
  *
  * @return void
  */
 protected function addMocks()
 {
     $resIteratorcallback = function () {
         $arguments = func_get_args();
         $arguments[2]['results'] = [['use_special' => false, 'price' => 10, 'final_price' => 20]];
     };
     $this->storeMock->expects($this->once())->method('getWebsiteId')->will($this->returnValue(0));
     $this->storeMock->expects($this->once())->method('getFrontendName')->will($this->returnValue('store name'));
     $this->catalogHelperMock->expects($this->once())->method('canApplyMsrp')->will($this->returnValue(false));
     $this->resourceIteratorMock->expects($this->once())->method('walk')->will($this->returnCallback($resIteratorcallback));
     $this->imageHelperMock->expects($this->once())->method('init')->will($this->returnSelf());
 }
Exemplo n.º 6
0
 public function testGetRssData()
 {
     $this->rssUrlBuilder->expects($this->once())->method('getUrl')->with(['type' => 'special_products', 'store_id' => 1])->will($this->returnValue('http://magento.com/rss/feed/index/type/special_products/store_id/1'));
     $item = $this->getItemMock();
     $this->rssModel->expects($this->once())->method('getProductsCollection')->will($this->returnValue([$item]));
     $this->msrpHelper->expects($this->once())->method('canApplyMsrp')->will($this->returnValue(false));
     $this->localeDate->expects($this->once())->method('formatDateTime')->will($this->returnValue(date('Y-m-d')));
     $this->priceCurrency->expects($this->any())->method('convertAndFormat')->will($this->returnArgument(0));
     $this->imageHelper->expects($this->once())->method('init')->with($item, 'rss_thumbnail')->will($this->returnSelf());
     $this->imageHelper->expects($this->once())->method('getUrl')->will($this->returnValue('image_link'));
     $this->outputHelper->expects($this->once())->method('productAttribute')->will($this->returnValue(''));
     $data = ['title' => 'Store 1 - Special Products', 'description' => 'Store 1 - Special Products', 'link' => 'http://magento.com/rss/feed/index/type/special_products/store_id/1', 'charset' => 'UTF-8', 'language' => 'en_US', 'entries' => [['title' => 'Product Name', 'link' => 'http://magento.com/product-name.html']]];
     $rssData = $this->block->getRssData();
     $description = $rssData['entries'][0]['description'];
     unset($rssData['entries'][0]['description']);
     $this->assertEquals($data, $rssData);
     $this->assertContains('<a href="http://magento.com/product-name.html"><', $description);
     $this->assertContains(sprintf('<p>Price:  Special Price: 10<br />Special Expires On: %s</p>', date('Y-m-d')), $description);
     $this->assertContains('<img src="image_link" alt="" border="0" align="left" height="75" width="75" />', $description);
 }