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->configMock = $this->getMockBuilder(ConfigInterface::class)
74 ->setMethods([
'getComposableTypes'])
75 ->getMockForAbstractClass();
83 return $this->objectManager->getObject(GroupedProductDataProvider::class, [
85 'primaryFieldName' =>
'testPrimaryFieldName',
86 'requestFieldName' =>
'testRequestFieldName',
87 'collectionFactory' => $this->collectionFactoryMock,
88 'request' => $this->requestMock,
89 'config' => $this->configMock,
90 'addFieldStrategies' => [],
91 'addFilterStrategies' => [],
99 $items = [
'testProduct1',
'testProduct2'];
101 'totalRecords' => count(
$items),
105 $this->configMock->expects($this->once())
106 ->method(
'getComposableTypes')
107 ->willReturn([self::ALLOWED_TYPE]);
108 $this->collectionMock->expects($this->once())
111 $this->collectionMock->expects($this->once())
112 ->method(
'addAttributeToFilter')
113 ->with(
'type_id', [self::ALLOWED_TYPE]);
114 $this->collectionMock->expects($this->once())
117 $this->collectionMock->expects($this->once())
119 ->willReturn(count(
$items));
121 $this->assertEquals($expectedData, $this->
getModel()->getData());
126 $this->assertInstanceOf(Collection::class, $this->
getModel()->getCollection());