10 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
53 $this->collectionMock = $this->getMockBuilder(Collection::class)
54 ->disableOriginalConstructor()
56 $this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
57 ->disableOriginalConstructor()
58 ->setMethods([
'create'])
60 $this->collectionFactoryMock->expects($this->once())
62 ->willReturn($this->collectionMock);
63 $this->poolMock = $this->getMockBuilder(Pool::class)
64 ->disableOriginalConstructor()
66 $this->modifierMockOne = $this->getMockBuilder(ModifierInterface::class)
67 ->setMethods([
'getData',
'getMeta'])
68 ->getMockForAbstractClass();
70 $this->model = $this->objectManager->getObject(ProductDataProvider::class, [
72 'primaryFieldName' =>
'testPrimaryFieldName',
73 'requestFieldName' =>
'testRequestFieldName',
74 'collectionFactory' => $this->collectionFactoryMock,
75 'pool' => $this->poolMock,
81 $expectedMeta = [
'meta_key' =>
'meta_value'];
83 $this->poolMock->expects($this->once())
84 ->method(
'getModifiersInstances')
85 ->willReturn([$this->modifierMockOne]);
86 $this->modifierMockOne->expects($this->once())
87 ->method(
'modifyMeta')
88 ->willReturn($expectedMeta);
90 $this->assertSame($expectedMeta, $this->model->getMeta());
95 $expectedMeta = [
'data_key' =>
'data_value'];
97 $this->poolMock->expects($this->once())
98 ->method(
'getModifiersInstances')
99 ->willReturn([$this->modifierMockOne]);
100 $this->modifierMockOne->expects($this->once())
101 ->method(
'modifyData')
102 ->willReturn($expectedMeta);
104 $this->assertSame($expectedMeta, $this->model->getData());