CurrencyTest.php
3 years ago
EmailTest.php
3 years ago
IntegerTest.php
3 years ago
MaxTest.php
3 years ago
MinTest.php
3 years ago
NumericTest.php
3 years ago
RequiredTest.php
3 years ago
SizeTest.php
3 years ago
CurrencyTest.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace StellarWP\Validation\Tests\Unit\Rules; |
| 6 | |
| 7 | use StellarWP\Validation\Rules\Currency; |
| 8 | use StellarWP\Validation\Tests\TestCase; |
| 9 | class CurrencyTest extends TestCase |
| 10 | { |
| 11 | /** |
| 12 | * @unreleased |
| 13 | * @dataProvider currencyProvider |
| 14 | */ |
| 15 | public function testCurrencyValidations($currency, $shouldPass) |
| 16 | { |
| 17 | $rule = new Currency(); |
| 18 | |
| 19 | if ( $shouldPass ) { |
| 20 | self::assertValidationRulePassed($rule, $currency); |
| 21 | } else { |
| 22 | self::assertValidationRuleFailed($rule, $currency); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @unreleased |
| 28 | */ |
| 29 | public function currencyProvider(): array |
| 30 | { |
| 31 | return [ |
| 32 | // normal |
| 33 | ['USD', true], |
| 34 | ['CAD', true], |
| 35 | |
| 36 | // should not be case-sensitive |
| 37 | ['jpy', true], |
| 38 | ['EuR', true], |
| 39 | |
| 40 | // should fail |
| 41 | ['US', false], |
| 42 | ['USDD', false], |
| 43 | ['US D', false], |
| 44 | ['US-D', false], |
| 45 | ['ABC', false], |
| 46 | ['123', false], |
| 47 | ]; |
| 48 | } |
| 49 | } |
| 50 |