12 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
51 $this->requestMock = $this->getMockBuilder(RequestInterface::class)
52 ->getMockForAbstractClass();
53 $this->collectionMock = $this->getMockBuilder(Collection::class)
54 ->disableOriginalConstructor()
59 'addAttributeToFilter',
62 'addFilterByRequiredOptions',
66 $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
67 ->disableOriginalConstructor()
68 ->setMethods([
'create'])
70 $this->collectionFactoryMock->expects($this->any())
72 ->willReturn($this->collectionMock);
73 $this->dataHelperMock = $this->getMockBuilder(Data::class)
74 ->disableOriginalConstructor()
75 ->setMethods([
'getAllowedSelectionTypes'])
84 return $this->objectManager->getObject(BundleDataProvider::class, [
86 'primaryFieldName' =>
'testPrimaryFieldName',
87 'requestFieldName' =>
'testRequestFieldName',
88 'collectionFactory' => $this->collectionFactoryMock,
89 'request' => $this->requestMock,
90 'dataHelper' => $this->dataHelperMock,
91 'addFieldStrategies' => [],
92 'addFilterStrategies' => [],
100 $items = [
'testProduct1',
'testProduct2'];
102 'totalRecords' => count(
$items),
106 $this->dataHelperMock->expects($this->once())
107 ->method(
'getAllowedSelectionTypes')
108 ->willReturn([self::ALLOWED_TYPE]);
109 $this->collectionMock->expects($this->once())
112 $this->collectionMock->expects($this->once())
113 ->method(
'addAttributeToFilter')
114 ->with(
'type_id', [self::ALLOWED_TYPE]);
115 $this->collectionMock->expects($this->once())
116 ->method(
'addFilterByRequiredOptions');
117 $this->collectionMock->expects($this->once())
118 ->method(
'addStoreFilter')
119 ->with(\
Magento\Store\Model\Store::DEFAULT_STORE_ID);
120 $this->collectionMock->expects($this->once())
123 $this->collectionMock->expects($this->once())
125 ->willReturn(count(
$items));
127 $this->assertEquals($expectedData, $this->
getModel()->getData());
132 $this->assertInstanceOf(Collection::class, $this->
getModel()->getCollection());