diff --git a/tests/unit/CartRule/ValidatorCest.php b/tests/unit/CartRule/ValidatorCest.php index e69de29bb..cde65a970 100644 --- a/tests/unit/CartRule/ValidatorCest.php +++ b/tests/unit/CartRule/ValidatorCest.php @@ -0,0 +1,99 @@ +executeFunction(Validator::class, 'validateArrayValues', [ + 'attributeValue' => $scenario['inputArray'], + 'conditionValue' => $scenario['conditionValue'] + ]); + + $I->assertEquals($scenario['expectResult'], $result); + } + + protected function getScenariosForTestValidateArrayValues(): array + { + return [ + [ + 'inputArray' => [], + 'conditionValue' => '', + 'expectResult' => false, + ], + [ + 'inputArray' => ['firstDimension' => 'firstValue'], + 'conditionValue' => 'anotherValue', + 'expectResult' => false, + ], + [ + 'inputArray' => ['firstDimension' => 'firstValue'], + 'conditionValue' => 'firstValue', + 'expectResult' => true, + ], + [ + 'inputArray' => [ + 'firstDimension' => 'firstValue', + 'secondDimension' => [ + 'secondKey' => 'secondValue' + ] + ], + 'conditionValue' => 'anotherValue', + 'expectResult' => false, + ], + [ + 'inputArray' => [ + 'firstDimension' => 'firstValue', + 'secondDimension' => [ + 'secondKey' => 'secondValue' + ] + ], + 'conditionValue' => 'secondValue', + 'expectResult' => true, + ], + [ + 'inputArray' => [ + 'firstDimension' => 'firstValue', + 'secondDimension' => [ + 'secondKey' => 'secondValue', + 'thirdDimension' => [ + 'thirdKey' => 'thirdValue' + ] + ] + ], + 'conditionValue' => 'thirdValue', + 'expectResult' => true, + ], + [ + 'inputArray' => [ + 'firstDimension' => 'firstValue', + 'secondDimension' => [ + 'secondKey' => 'secondValue', + 'thirdDimension' => [ + 'thirdKey' => 'thirdValue' + ] + ], + 'secondDimension2' => [ + 'secondKey2' => 'secondValue2', + 'thirdDimension2' => [ + 'thirdKey2' => 'thirdValue2' + ] + ] + ], + 'conditionValue' => 'thirdValue2', + 'expectResult' => true, + ], + ]; + } +} \ No newline at end of file