Skip to content

Commit 1a1dc6a

Browse files
committed
ACPT-1316: Fix Sales Webapi GraphQl tests on MTS
1 parent 51b2bc6 commit 1a1dc6a

File tree

1 file changed

+17
-3
lines changed
  • app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute

1 file changed

+17
-3
lines changed

app/code/Magento/Eav/Test/Unit/Model/Validator/Attribute/DataTest.php

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Magento\Eav\Model\AttributeDataFactory;
1414
use Magento\Eav\Model\Entity\AbstractEntity;
1515
use Magento\Eav\Model\Validator\Attribute\Data;
16+
use Magento\Framework\App\ObjectManager;
1617
use Magento\Framework\DataObject;
1718
use Magento\Framework\Model\AbstractModel;
1819
use Magento\Framework\ObjectManagerInterface;
@@ -35,6 +36,11 @@ class DataTest extends TestCase
3536
*/
3637
private $model;
3738

39+
/**
40+
* @var \Magento\Eav\Model\Config|MockObject
41+
*/
42+
private $eavConfigMock;
43+
3844
/**
3945
* @inheritdoc
4046
*/
@@ -49,7 +55,12 @@ protected function setUp(): void
4955
]
5056
)
5157
->getMock();
52-
58+
$this->createMock(ObjectManagerInterface::class);
59+
ObjectManager::setInstance($this->createMock(ObjectManagerInterface::class));
60+
$this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
61+
->onlyMethods(['getEntityType'])
62+
->disableOriginalConstructor()
63+
->getMock();
5364
$this->model = new Data($this->attrDataFactory);
5465
}
5566

@@ -205,13 +216,16 @@ public function testIsValidAttributesFromCollection(): void
205216
'is_visible' => true,
206217
]
207218
);
219+
$entityTypeCode = 'entity_type_code';
208220
$collection = $this->getMockBuilder(DataObject::class)
209221
->addMethods(['getItems'])->getMock();
210222
$collection->expects($this->once())->method('getItems')->willReturn([$attribute]);
211223
$entityType = $this->getMockBuilder(DataObject::class)
212-
->addMethods(['getAttributeCollection'])
224+
->addMethods(['getAttributeCollection','getEntityTypeCode'])
213225
->getMock();
226+
$entityType->expects($this->atMost(2))->method('getEntityTypeCode')->willReturn($entityTypeCode);
214227
$entityType->expects($this->once())->method('getAttributeCollection')->willReturn($collection);
228+
$this->eavConfigMock->expects($this->once())->method('getEntityType')->with($entityTypeCode)->willReturn($entityType);
215229
$entity = $this->_getEntityMock();
216230
$entity->expects($this->once())->method('getResource')->willReturn($resource);
217231
$entity->expects($this->once())->method('getEntityType')->willReturn($entityType);
@@ -235,7 +249,7 @@ public function testIsValidAttributesFromCollection(): void
235249
)->willReturn(
236250
$dataModel
237251
);
238-
$validator = new Data($attrDataFactory);
252+
$validator = new Data($attrDataFactory, $this->eavConfigMock);
239253

240254
$validator->setData(['attribute' => 'new_test_data']);
241255
$this->assertTrue($validator->isValid($entity));

0 commit comments

Comments
 (0)