sarga/tests/unit/CartRule/ValidatorCest.php

99 lines
3.1 KiB
PHP
Raw Normal View History

bagisto master backmerge (#26) * introduce cronjob to automatically deactivate expired events * remove irrelevant code * extend cart rule validation with search in cart item additional * add additional to all languages * add ValidatorCest * add ValidatorCest * Fixed case sensitivity typo in Bundle class * Update 503.blade.php * Added customer group price * Fixed bundle type class compatablity issue * Refactor some changes Co-authored-by: Florian Bosdorff <26360670+bosix@users.noreply.github.com> * add english translation to foreign languages * fix compatibility issue to AbstractType * check if product_id exists * make a prefix to the copied cart rule ('copy of XXX') and properly save related channels and customer groups after replication * add table, lists, link and hr functionality to editor * Issue #3164 fixed * Turkish Language added and English language duplicate rows deleted. * Turkish Language added and English language duplicate rows deleted. * Turkish Language added and English language duplicate rows deleted. * Issue #3113 fixed * fix tiny issues due to code guidelines * add default value for search term * fix typo * Fixed typo in customer group price migration * Issue #3171 fixed * Issue #3070 fixed * minified jquery-ez-plus file * Issue #3160 fixed Co-authored-by: Shubham Mehrotra <shubh0896m@gmail.com> Co-authored-by: Matt April <matthew.japril@gmail.com> Co-authored-by: bhumikaisarani <63963172+bhumikaisarani@users.noreply.github.com> Co-authored-by: Jitendra Singh <39991107+jitendra-webkul@users.noreply.github.com> Co-authored-by: Pranshu Tomar <pranshutomar@Pranshus-MacBook-Air.local> Co-authored-by: Florian Bosdorff <26360670+bosix@users.noreply.github.com> Co-authored-by: Herbert Maschke <thyseus@pm.me> Co-authored-by: phillipmohr <phillip.mohr@sellerboost.de> Co-authored-by: İlyas Okay <ilyasokay@hotmail.com> Co-authored-by: Florian Bosdorff <florian.bosdorff@haendlerbund.de> Co-authored-by: phillipcodes <57101430+phillipcodes@users.noreply.github.com>
2020-06-09 05:55:56 +00:00
<?php
namespace Tests\Unit\CartRule;
use Codeception\Example;
use UnitTester;
use Webkul\Rule\Helpers\Validator;
class ValidatorCest
{
/**
* @param UnitTester $I
* @param Example $scenario
*
* @dataProvider getScenariosForTestValidateArrayValues
*/
public function testValidateArrayValues(UnitTester $I, Example $scenario): void
{
$result = $I->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,
],
];
}
}