6 declare(strict_types=1);
23 private $attributeValidation;
28 private $storeManagerMock;
38 private $allowedEntityTypes;
48 private $isProceedMockCalled =
false;
58 private $attributeMock;
69 $this->attributeMock = $this->getMockBuilder(AbstractBackend::class)
70 ->setMethods([
'getAttributeCode'])
71 ->getMockForAbstractClass();
72 $this->subjectMock = $this->getMockBuilder(AbstractBackend::class)
73 ->setMethods([
'getAttribute'])
74 ->getMockForAbstractClass();
75 $this->subjectMock->expects($this->any())
76 ->method(
'getAttribute')
77 ->willReturn($this->attributeMock);
79 $this->storeMock = $this->getMockBuilder(StoreInterface::class)
80 ->setMethods([
'getId'])
81 ->getMockForAbstractClass();
82 $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
83 ->setMethods([
'getStore'])
84 ->getMockForAbstractClass();
85 $this->storeManagerMock->expects($this->any())
87 ->willReturn($this->storeMock);
89 $this->entityMock = $this->getMockBuilder(DataObject::class)
90 ->setMethods([
'getData'])
93 $this->allowedEntityTypes = [$this->entityMock];
95 $this->proceedMock =
function () {
96 $this->isProceedMockCalled =
true;
100 AttributeValidation::class,
102 'storeManager' => $this->storeManagerMock,
103 'allowedEntityTypes' => $this->allowedEntityTypes,
118 $this->isProceedMockCalled =
false;
121 $this->storeMock->expects($this->once())
124 if ($defaultStoreUsed) {
125 $this->attributeMock->expects($this->once())
126 ->method(
'getAttributeCode')
128 $this->entityMock->expects($this->at(0))
131 $this->entityMock->expects($this->at(1))
137 $this->attributeValidation->aroundValidate($this->subjectMock, $this->proceedMock, $this->entityMock);
138 $this->assertSame($shouldProceedRun, $this->isProceedMockCalled);
testAroundValidate(bool $shouldProceedRun, bool $defaultStoreUsed, $storeId)
aroundValidateDataProvider()