public function testGetProductAttributes() { $expectedResult = ['attribute_one', 'attribute_two', 'attribute_three']; $this->_catalogConfig->expects($this->once())->method('getProductAttributes')->willReturn(['attribute_one', 'attribute_two']); $this->_attributeConfig->expects($this->once())->method('getAttributeNames')->with('wishlist_item')->willReturn(['attribute_three']); $this->assertEquals($expectedResult, $this->model->getProductAttributes()); }
protected function generalGetProductCollection() { $this->eventManager->expects($this->once())->method('dispatch')->will($this->returnValue(true)); $this->scopeConfig->expects($this->once())->method('getValue')->withAnyParameters()->willReturn(false); $this->cacheState->expects($this->atLeastOnce())->method('isEnabled')->withAnyParameters()->willReturn(false); $this->catalogConfig->expects($this->once())->method('getProductAttributes')->willReturn([]); $this->localDate->expects($this->any())->method('date')->willReturn(new \DateTime('now', new \DateTimeZone('UTC'))); $this->context->expects($this->once())->method('getEventManager')->willReturn($this->eventManager); $this->context->expects($this->once())->method('getScopeConfig')->willReturn($this->scopeConfig); $this->context->expects($this->once())->method('getCacheState')->willReturn($this->cacheState); $this->context->expects($this->once())->method('getCatalogConfig')->willReturn($this->catalogConfig); $this->context->expects($this->once())->method('getLocaleDate')->willReturn($this->localDate); $this->productCollection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Collection')->setMethods(['setVisibility', 'addMinimalPrice', 'addFinalPrice', 'addTaxPercents', 'addAttributeToSelect', 'addUrlRewrite', 'addStoreFilter', 'addAttributeToSort', 'setPageSize', 'setCurPage', 'addAttributeToFilter'])->disableOriginalConstructor()->getMock(); $this->productCollection->expects($this->once())->method('setVisibility')->willReturnSelf(); $this->productCollection->expects($this->once())->method('addMinimalPrice')->willReturnSelf(); $this->productCollection->expects($this->once())->method('addFinalPrice')->willReturnSelf(); $this->productCollection->expects($this->once())->method('addTaxPercents')->willReturnSelf(); $this->productCollection->expects($this->once())->method('addAttributeToSelect')->willReturnSelf(); $this->productCollection->expects($this->once())->method('addUrlRewrite')->willReturnSelf(); $this->productCollection->expects($this->once())->method('addStoreFilter')->willReturnSelf(); $this->productCollection->expects($this->once())->method('addAttributeToSort')->willReturnSelf(); $this->productCollection->expects($this->atLeastOnce())->method('setCurPage')->willReturnSelf(); $this->productCollection->expects($this->any())->method('addAttributeToFilter')->willReturnSelf(); }
public function testToOptionalArray() { $except = [['label' => __('Position'), 'value' => 'position'], ['label' => 'testLabel', 'value' => 'testAttributeCode']]; $this->catalogConfig->expects($this->any())->method('getAttributesUsedForSortBy')->will($this->returnValue([['frontend_label' => 'testLabel', 'attribute_code' => 'testAttributeCode']])); $this->assertEquals($except, $this->model->toOptionArray()); }