本文整理汇总了PHP中Magento\Catalog\Api\Data\ProductInterface::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductInterface::expects方法的具体用法?PHP ProductInterface::expects怎么用?PHP ProductInterface::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Api\Data\ProductInterface
的用法示例。
在下文中一共展示了ProductInterface::expects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAfterLoadWithExistingExtensionAttributes
public function testAfterLoadWithExistingExtensionAttributes()
{
// test when extension attributes already exist
$this->productMock->expects($this->once())->method('getExtensionAttributes')->willReturn($this->productExtensionMock);
$this->productExtensionFactoryMock->expects($this->never())->method('create');
$this->assertEquals($this->productMock, $this->plugin->afterLoad($this->productMock));
}
示例2: setUp
protected function setUp()
{
$this->objectManager = new ObjectManager($this);
$this->locatorMock = $this->getMockBuilder(LocatorInterface::class)->getMockForAbstractClass();
$this->productMock = $this->getMockBuilder(ProductInterface::class)->setMethods(['getId', 'getTypeId'])->getMockForAbstractClass();
$this->productMock->expects($this->any())->method('getId')->willReturn(self::PRODUCT_ID);
$this->productMock->expects($this->any())->method('getTypeId')->willReturn(GroupedProductType::TYPE_CODE);
$this->linkedProductMock = $this->getMockBuilder(ProductInterface::class)->setMethods(['getId', 'getName', 'getPrice'])->getMockForAbstractClass();
$this->linkedProductMock->expects($this->any())->method('getId')->willReturn(self::LINKED_PRODUCT_ID);
$this->linkedProductMock->expects($this->any())->method('getName')->willReturn(self::LINKED_PRODUCT_NAME);
$this->linkedProductMock->expects($this->any())->method('getPrice')->willReturn(self::LINKED_PRODUCT_PRICE);
$this->linkMock = $this->getMockBuilder(ProductLinkInterface::class)->setMethods(['getLinkType', 'getLinkedProductSku', 'getPosition', 'getExtensionAttributes'])->getMockForAbstractClass();
$this->linkExtensionMock = $this->getMockBuilder(ProductLinkExtensionInterface::class)->setMethods(['getQty'])->getMockForAbstractClass();
$this->linkExtensionMock->expects($this->any())->method('getQty')->willReturn(self::LINKED_PRODUCT_QTY);
$this->linkMock->expects($this->any())->method('getExtensionAttributes')->willReturn($this->linkExtensionMock);
$this->linkMock->expects($this->any())->method('getPosition')->willReturn(self::LINKED_PRODUCT_POSITION);
$this->linkMock->expects($this->any())->method('getLinkedProductSku')->willReturn(self::LINKED_PRODUCT_SKU);
$this->linkMock->expects($this->any())->method('getLinkType')->willReturn(Grouped::LINK_TYPE);
$this->linkRepositoryMock = $this->getMockBuilder(ProductLinkRepositoryInterface::class)->setMethods(['getList'])->getMockForAbstractClass();
$this->linkRepositoryMock->expects($this->any())->method('getList')->with($this->productMock)->willReturn([$this->linkMock]);
$this->productRepositoryMock = $this->getMockBuilder(ProductRepositoryInterface::class)->setMethods(['get'])->getMockForAbstractClass();
$this->productRepositoryMock->expects($this->any())->method('get')->with(self::LINKED_PRODUCT_SKU)->willReturn($this->linkedProductMock);
$this->storeMock = $this->getMockBuilder(StoreInterface::class)->setMethods(['getId'])->getMockForAbstractClass();
$this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
$this->locatorMock->expects($this->any())->method('getStore')->willReturn($this->storeMock);
}
示例3: testModifyMeta
/**
* @return void
*/
public function testModifyMeta()
{
$this->locatorMock->expects($this->exactly(2))->method('getProduct')->willReturn($this->productMock);
$this->productMock->expects($this->any())->method('getTypeId');
$this->arrayManagerMock->expects($this->exactly(3))->method('set')->willReturn([]);
$this->assertEquals([], $this->downloadablePanel->modifyMeta([]));
}
示例4: testDisallowModifyMeta
public function testDisallowModifyMeta()
{
$meta = ['some meta'];
$modifiers = ['modifier1', 'modifier2'];
$this->productMock->expects(static::any())->method('getTypeId')->willReturn(ConfigurableType::TYPE_CODE);
$this->allowedProductTypesMock->expects(static::once())->method('isAllowedProductType')->with($this->productMock)->willReturn(false);
$this->objectManagerMock->expects(static::never())->method('get');
$this->assertSame($meta, $this->createCompositeModifier($modifiers)->modifyMeta($meta));
}
示例5: testModifyMetaWithException
/**
* @return void
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Type "SomeClass" is not an instance of
* Magento\Ui\DataProvider\Modifier\ModifierInterface
*/
public function testModifyMetaWithException()
{
/** @var \Exception|MockObject $modifierMock */
$modifierMock = $this->getMock(\Exception::class);
$modifierMock->expects($this->never())->method('modifyMeta');
$this->productMock->expects($this->once())->method('getTypeId')->willReturn(Type::TYPE_CODE);
$this->objectManagerMock->expects($this->once())->method('get')->with($this->modifierClass)->willReturn($modifierMock);
$this->composite->modifyMeta($this->meta);
}
示例6: testGetLinksTitle
/**
* @param int|null $id
* @param string $typeId
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectedGetTitle
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectedGetValue
* @return void
* @dataProvider getLinksTitleDataProvider
*/
public function testGetLinksTitle($id, $typeId, $expectedGetTitle, $expectedGetValue)
{
$title = 'My Title';
$this->locatorMock->expects($this->any())->method('getProduct')->willReturn($this->productMock);
$this->productMock->expects($this->once())->method('getId')->willReturn($id);
$this->productMock->expects($this->any())->method('getTypeId')->willReturn($typeId);
$this->productMock->expects($expectedGetTitle)->method('getLinksTitle')->willReturn($title);
$this->scopeConfigMock->expects($expectedGetValue)->method('getValue')->willReturn($title);
$this->assertEquals($title, $this->links->getLinksTitle());
}
示例7: testModifyMeta
/**
* @return void
*/
public function testModifyMeta()
{
$this->locatorMock->expects($this->once())->method('getProduct')->willReturn($this->productMock);
$this->productMock->expects($this->once())->method('getTypeId');
$this->storeManagerMock->expects($this->once())->method('isSingleStoreMode');
$this->typeUploadMock->expects($this->once())->method('toOptionArray');
$this->urlBuilderMock->expects($this->once())->method('addSessionParam')->willReturnSelf();
$this->urlBuilderMock->expects($this->once())->method('getUrl');
$this->arrayManagerMock->expects($this->exactly(6))->method('set')->willReturn([]);
$this->assertEquals([], $this->samples->modifyMeta([]));
}
示例8: testModifyMeta
/**
* @return void
*/
public function testModifyMeta()
{
$this->locatorMock->expects($this->once())->method('getProduct')->willReturn($this->productMock);
$this->productMock->expects($this->any())->method('getTypeId');
$this->storeManagerMock->expects($this->exactly(2))->method('isSingleStoreMode');
$this->typeUploadMock->expects($this->exactly(2))->method('toOptionArray');
$this->shareableMock->expects($this->once())->method('toOptionArray');
$this->urlBuilderMock->expects($this->exactly(2))->method('addSessionParam')->willReturnSelf();
$this->urlBuilderMock->expects($this->exactly(2))->method('getUrl');
$currencyMock = $this->getMock(\Magento\Directory\Model\Currency::class, [], [], '', false);
$currencyMock->expects($this->once())->method('getCurrencySymbol');
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->setMethods(['getBaseCurrency'])->getMockForAbstractClass();
$storeMock->expects($this->once())->method('getBaseCurrency')->willReturn($currencyMock);
$this->locatorMock->expects($this->once())->method('getStore')->willReturn($storeMock);
$this->arrayManagerMock->expects($this->exactly(9))->method('set')->willReturn([]);
$this->assertEquals([], $this->links->modifyMeta([]));
}
示例9: testAroundSaveWithNotAssignedStockItemId
/**
* @expectedException \Magento\Framework\Exception\LocalizedException
* @expectedExceptionMessage Invalid stock item id: 35. Assigned stock item id is 40
*/
public function testAroundSaveWithNotAssignedStockItemId()
{
$stockId = 80;
$stockItemId = 35;
$defaultScopeId = 100;
$defaultStockId = 80;
$storedStockitemId = 40;
$this->stockItem->expects($this->once())->method('getStockId')->willReturn($stockId);
$this->stockRegistry->expects($this->once())->method('getStock')->with($defaultScopeId)->willReturn($this->defaultStock);
$this->stockConfiguration->expects($this->once())->method('getDefaultScopeId')->willReturn($defaultScopeId);
$this->defaultStock->expects($this->once())->method('getStockId')->willReturn($defaultStockId);
$this->product->expects($this->once())->method('getExtensionAttributes')->willReturn($this->productExtension);
$this->productExtension->expects($this->once())->method('getStockItem')->willReturn($this->stockItem);
$this->stockItem->expects($this->once())->method('getItemId')->willReturn($stockItemId);
$storedStockItem = $this->getMockBuilder(StockItemInterface::class)->setMethods(['getItemId'])->getMockForAbstractClass();
$storedStockItem->expects($this->once())->method('getItemId')->willReturn($storedStockitemId);
$this->stockRegistry->expects($this->once())->method('getStockItem')->willReturn($storedStockItem);
$this->plugin->aroundSave($this->productRepository, $this->closure, $this->product);
}
示例10: testAroundSave
public function testAroundSave()
{
$productId = 5494;
$websiteId = 1;
$storeId = 2;
$sku = 'my product that needs saving';
$this->productMock->expects($this->once())->method('getExtensionAttributes')->willReturn($this->productExtensionMock);
$this->productExtensionMock->expects($this->once())->method('getStockItem')->willReturn($this->stockItemMock);
$storeMock = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock();
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
$this->storeManager->expects($this->once())->method('getStore')->with($storeId)->willReturn($storeMock);
$this->savedProductMock->expects($this->once())->method('getId')->willReturn($productId);
$this->savedProductMock->expects($this->atLeastOnce())->method('getStoreId')->willReturn($storeId);
$this->savedProductMock->expects($this->atLeastOnce())->method('getSku')->willReturn($sku);
$this->stockItemMock->expects($this->once())->method('setProductId')->with($productId);
$this->stockItemMock->expects($this->once())->method('setWebsiteId')->with($websiteId);
$this->stockRegistry->expects($this->once())->method('updateStockItemBySku')->with($sku, $this->stockItemMock);
$newProductMock = $this->getMockBuilder('Magento\\Catalog\\Api\\Data\\ProductInterface')->disableOriginalConstructor()->getMock();
$this->productRepositoryMock->expects($this->once())->method('get')->with($sku, false, $storeId, true)->willReturn($newProductMock);
$this->assertEquals($newProductMock, $this->plugin->aroundSave($this->productRepositoryMock, $this->closureMock, $this->productMock));
}
示例11: canShowDownloadablePanel
/**
* @param string $typeId
* @return void
*/
protected function canShowDownloadablePanel($typeId)
{
$this->locatorMock->expects($this->once())->method('getProduct')->willReturn($this->productMock);
$this->productMock->expects($this->once())->method('getTypeId')->willReturn($typeId);
}