26 private $resourceConnection;
36 private $linkedProductSelectBuilder;
41 private $collectionFactory;
46 private $productCollection;
51 private $storeManagerMock;
60 $this->connection = $this
61 ->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)
63 $this->resourceConnection = $this
64 ->getMockBuilder(\
Magento\Framework\
App\ResourceConnection::class)
65 ->disableOriginalConstructor()
66 ->setMethods([
'getConnection'])
68 $this->resourceConnection->expects($this->once())->method(
'getConnection')->willReturn($this->connection);
69 $this->linkedProductSelectBuilder = $this
70 ->getMockBuilder(LinkedProductSelectBuilderInterface::class)
71 ->setMethods([
'build'])
73 $this->productCollection = $this
75 ->disableOriginalConstructor()
76 ->setMethods([
'addAttributeToSelect',
'addIdFilter',
'getItems'])
78 $this->collectionFactory = $this
80 ->disableOriginalConstructor()
81 ->setMethods([
'create'])
83 $this->collectionFactory->expects($this->once())->method(
'create')->willReturn($this->productCollection);
84 $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
85 ->getMockForAbstractClass();
86 $this->storeMock = $this->getMockBuilder(StoreInterface::class)
87 ->setMethods([
'getId'])
88 ->getMockForAbstractClass();
94 'resourceConnection' => $this->resourceConnection,
95 'linkedProductSelectBuilder' => $this->linkedProductSelectBuilder,
96 'collectionFactory' => $this->collectionFactory,
97 'storeManager' => $this->storeManagerMock,
105 $linkedProducts = [
'some',
'linked',
'products',
'dataobjects'];
106 $product = $this->getMockBuilder(ProductInterface::class)->disableOriginalConstructor()->getMock();
108 $this->linkedProductSelectBuilder->expects($this->any())->method(
'build')->with(
$productId)->willReturn([]);
109 $this->productCollection
110 ->expects($this->once())
111 ->method(
'addAttributeToSelect')
112 ->with([
'price',
'special_price',
'special_from_date',
'special_to_date',
'tax_class_id'])
114 $this->productCollection->expects($this->once())->method(
'addIdFilter')->willReturnSelf();
115 $this->productCollection->expects($this->once())->method(
'getItems')->willReturn($linkedProducts);
116 $this->storeManagerMock->expects($this->any())
119 ->willReturn($this->storeMock);
120 $this->storeMock->expects($this->any())
124 $this->assertEquals($linkedProducts, $this->model->getProducts(
$product));