Skip to content

Commit 40dd1c8

Browse files
committed
ACP2E-2464: [Cloud] Can not save configurable child product by admin user with website permission
- added unit test - adjusted static issue
1 parent 9e866ae commit 40dd1c8

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/Validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function afterValidate(Rule $rule, $validateResult, DataObject $product)
5656
$product->getStoreId()
5757
);
5858
$validateResult = $rule->getConditions()->validate($configurableProduct);
59-
// If any of configurable product is valid for current rule, then their sub-product must be valid too
59+
//If any of configurable product is valid for current rule, then their sub-product must be valid too
6060
if ($validateResult) {
6161
break;
6262
}

app/code/Magento/CatalogRuleConfigurable/Test/Unit/Plugin/CatalogRule/Model/Rule/ValidationTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,32 @@ protected function setUp(): void
6666
);
6767
}
6868

69+
/**
70+
* @return void
71+
*/
72+
public function testAfterValidateConfigurableProductException(): void
73+
{
74+
$validationResult = false;
75+
$parentsIds = [2];
76+
$productId = 1;
77+
78+
$this->productMock->expects($this->once())
79+
->method('getId')
80+
->willReturn($productId);
81+
$this->configurableMock->expects($this->once())
82+
->method('getParentIdsByChild')
83+
->with($productId)
84+
->willReturn($parentsIds);
85+
$this->productRepositoryMock->expects($this->once())
86+
->method('getById')
87+
->willThrowException(new \Exception('Faulty configurable product'));
88+
89+
$this->assertSame(
90+
$validationResult,
91+
$this->validation->afterValidate($this->ruleMock, $validationResult, $this->productMock)
92+
);
93+
}
94+
6995
/**
7096
* @param $parentsIds
7197
* @param $validationResult

0 commit comments

Comments
 (0)