From 4f7378a88d37345fed661e85c3ece786cf7328fb Mon Sep 17 00:00:00 2001 From: Annika Wolff Date: Thu, 28 May 2020 14:17:36 +0200 Subject: [PATCH] add ValidatorCest --- tests/unit/CartRule/ValidatorCest.php | 99 +++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) 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