10 use \Magento\Bundle\Model\Product\LinksList;
46 $this->linkFactoryMock = $this->createPartialMock(\
Magento\Bundle\Api\Data\LinkInterfaceFactory::class, [
49 $this->dataObjectHelperMock = $this->getMockBuilder(\
Magento\Framework\Api\DataObjectHelper::class)
50 ->disableOriginalConstructor()
52 $this->selectionMock = $this->createPartialMock(\
Magento\Catalog\Model\Product::class, [
53 'getSelectionPriceType',
54 'getSelectionPriceValue',
58 'getSelectionCanChangeQty',
62 $this->productMock = $this->createPartialMock(\
Magento\Catalog\Model\Product::class, [
68 $this->productTypeMock = $this->createMock(\
Magento\Bundle\Model\
Product\Type::class);
69 $this->model =
new LinksList($this->linkFactoryMock, $this->productTypeMock, $this->dataObjectHelperMock);
76 $this->productTypeMock->expects($this->once())
77 ->method(
'getSelectionsCollection')
79 ->willReturn([$this->selectionMock]);
80 $this->productMock->expects($this->exactly(2))->method(
'getPriceType')->willReturn(
'price_type');
81 $this->selectionMock->expects($this->once())
82 ->method(
'getSelectionPriceType')
83 ->willReturn(
'selection_price_type');
84 $this->selectionMock->expects($this->once())->method(
'getSelectionPriceValue')->willReturn(12);
85 $this->selectionMock->expects($this->once())->method(
'getData')->willReturn([
'some data']);
86 $this->selectionMock->expects($this->once())->method(
'getSelectionId')->willReturn($selectionId);
87 $this->selectionMock->expects($this->once())->method(
'getIsDefault')->willReturn(
true);
88 $this->selectionMock->expects($this->once())->method(
'getSelectionQty')->willReturn(66);
89 $this->selectionMock->expects($this->once())->method(
'getSelectionCanChangeQty')->willReturn(22);
90 $linkMock = $this->createMock(\
Magento\Bundle\Api\Data\LinkInterface::class);
91 $this->dataObjectHelperMock->expects($this->once())
92 ->method(
'populateWithArray')
93 ->with($linkMock, [
'some data'], \
Magento\Bundle\Api\Data\LinkInterface::class)->willReturnSelf();
94 $linkMock->expects($this->once())->method(
'setIsDefault')->with(
true)->willReturnSelf();
95 $linkMock->expects($this->once())->method(
'setQty')->with(66)->willReturnSelf();
96 $linkMock->expects($this->once())->method(
'setCanChangeQuantity')->with(22)->willReturnSelf();
97 $linkMock->expects($this->once())->method(
'setPrice')->with(12)->willReturnSelf();
98 $linkMock->expects($this->once())->method(
'setId')->with($selectionId)->willReturnSelf();
99 $linkMock->expects($this->once())
100 ->method(
'setPriceType')->with(
'selection_price_type')->willReturnSelf();
101 $this->linkFactoryMock->expects($this->once())->method(
'create')->willReturn($linkMock);
103 $this->assertEquals([$linkMock], $this->model->getItems($this->productMock,
$optionId));