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
RequiredTest.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace StellarWP\Validation\Tests\Unit\Rules; |
| 6 | |
| 7 | use StellarWP\Validation\Rules\Required; |
| 8 | use StellarWP\Validation\Tests\TestCase; |
| 9 | |
| 10 | class RequiredTest extends TestCase |
| 11 | { |
| 12 | public function testRuleValidation() |
| 13 | { |
| 14 | $rule = new Required(); |
| 15 | |
| 16 | // Value must be present in the array of values and not empty |
| 17 | self::assertValidationRulePassed($rule, 'hi', 'foo', ['foo' => 'hi']); |
| 18 | |
| 19 | // Value fails when present but empty |
| 20 | self::assertValidationRuleFailed($rule, '', 'foo', ['foo' => '']); |
| 21 | |
| 22 | // Value fails when null |
| 23 | self::assertValidationRuleFailed($rule, null, 'foo', ['foo' => null]); |
| 24 | |
| 25 | // Value fails when not present |
| 26 | self::assertValidationRuleFailed($rule, '', 'foo', []); |
| 27 | } |
| 28 | } |
| 29 |