22 private $relationsDataSaver;
27 private $resourceMock;
32 private $connectionMock;
37 private $productRelationMock;
41 $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
42 $this->resourceMock = $this->getMockBuilder(ResourceConnection::class)
43 ->disableOriginalConstructor()
45 $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
46 ->disableOriginalConstructor()
49 $this->productRelationMock = $this->getMockBuilder(Relation::class)
50 ->disableOriginalConstructor()
53 $this->relationsDataSaver =
$helper->getObject(
54 RelationsDataSaver::class,
56 'resource' => $this->resourceMock,
57 'productRelation' => $this->productRelationMock
65 $table_name=
'catalog_product_bundle_option';
66 $this->resourceMock->expects($this->once())->method(
'getConnection')->willReturn($this->connectionMock);
67 $this->resourceMock->expects($this->once())
68 ->method(
'getTableName')
69 ->with(
'catalog_product_bundle_option')
70 ->willReturn($table_name);
71 $this->connectionMock->expects($this->once())
72 ->method(
'insertOnDuplicate')
83 $this->relationsDataSaver->saveOptions(
$options);
88 $optionsValues = [1, 2];
89 $table_name=
'catalog_product_bundle_option_value';
91 $this->resourceMock->expects($this->once())->method(
'getConnection')->willReturn($this->connectionMock);
92 $this->resourceMock->expects($this->once())
93 ->method(
'getTableName')
94 ->with(
'catalog_product_bundle_option_value')
95 ->willReturn($table_name);
96 $this->connectionMock->expects($this->once())
97 ->method(
'insertOnDuplicate')
104 $this->relationsDataSaver->saveOptionValues($optionsValues);
109 $selections = [1, 2];
110 $table_name=
'catalog_product_bundle_selection';
112 $this->resourceMock->expects($this->once())->method(
'getConnection')->willReturn($this->connectionMock);
113 $this->resourceMock->expects($this->once())
114 ->method(
'getTableName')
115 ->with(
'catalog_product_bundle_selection')
116 ->willReturn($table_name);
117 $this->connectionMock->expects($this->once())
118 ->method(
'insertOnDuplicate')
127 'selection_price_type',
128 'selection_price_value',
130 'selection_can_change_qty' 134 $this->relationsDataSaver->saveSelections($selections);
142 $this->productRelationMock->expects($this->once())
143 ->method(
'processRelations')
146 $this->relationsDataSaver->saveProductRelations($parentId,
$children);
testSaveProductRelations()