Skip to content

Commit 469f260

Browse files
committed
ACP2E-3374: In Backend, default store values for product attributes (instead of expected admin values)
1 parent b98b2c9 commit 469f260

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

app/code/Magento/Rule/Test/Unit/Model/Condition/Product/AbstractProductTest.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,14 @@ private function verifySelectAllOptions(
463463
->disableOriginalConstructor()
464464
->getMock();
465465

466+
$storeId = '1';
467+
$storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)->getMock();
468+
$storeMock = $this->getMockBuilder(StoreInterface::class)->getMock();
469+
$storeMock->expects($this->atLeastOnce())->method('getId')->willReturn($storeId);
470+
$storeManagerMock->expects($this->atLeastOnce())->method('getStore')->willReturn($storeMock);
466471
$attrOptionFactory = $this->createPartialMock(OptionFactory::class, ['create']);
467472

473+
$attributeId = '42';
468474
$abstractAttributeMock = $this->getMockBuilder(AbstractAttribute::class)
469475
->addMethods(['getStoreId'])
470476
->onlyMethods(
@@ -475,21 +481,7 @@ private function verifySelectAllOptions(
475481
)
476482
->disableOriginalConstructor()
477483
->getMock();
478-
479-
$storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)->getMock();
480-
$storeMock = $this->getMockBuilder(StoreInterface::class)->getMock();
481-
482-
$attrObjectSourceMock = new Table($collectionFactory, $attrOptionFactory, $storeManagerMock);
483-
$attrObjectSourceMock->setAttribute($abstractAttributeMock);
484-
485-
$storeId = '1';
486-
$attributeId = '42';
487-
488484
$abstractAttributeMock->expects($this->atLeastOnce())->method('getStoreId')->willReturn(null);
489-
490-
$storeManagerMock->expects($this->atLeastOnce())->method('getStore')->willReturn($storeMock);
491-
$storeMock->expects($this->atLeastOnce())->method('getId')->willReturn($storeId);
492-
493485
$abstractAttributeMock->expects($this->atLeastOnce())->method('getId')->willReturn($attributeId);
494486

495487
$collectionFactory->expects($this->once())
@@ -518,6 +510,8 @@ private function verifySelectAllOptions(
518510
]
519511
);
520512

513+
$attrObjectSourceMock = new Table($collectionFactory, $attrOptionFactory, $storeManagerMock);
514+
$attrObjectSourceMock->setAttribute($abstractAttributeMock);
521515
$allOptionsValue = $attrObjectSourceMock->getAllOptions($expectedAttrObjSourceAllOptionsParam, true);
522516
$this->assertEquals($attrObjectSourceAllOptionsValue, $allOptionsValue);
523517
return $attrObjectSourceMock;

0 commit comments

Comments
 (0)