| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Give\Vendors\StellarWP\Validation\Tests\Unit\Rules; |
| 6 |
|
| 7 |
use Give\Vendors\StellarWP\Validation\Rules\Required; |
| 8 |
use Give\Vendors\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 |
|