PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / vendor / vendor-prefixed / stellarwp / validation / tests / unit / Rules / MinTest.php

MinTest.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at vendor/vendor-prefixed/stellarwp/validation/tests/unit/Rules/MinTest.php

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Give\Vendors\StellarWP\Validation\Tests\Unit\Rules;
6
7 use InvalidArgumentException;
8 use Give\Vendors\StellarWP\Validation\Exceptions\ValidationException;
9 use Give\Vendors\StellarWP\Validation\Rules\Min;
10 use Give\Vendors\StellarWP\Validation\Tests\TestCase;
11
12 class MinTest extends TestCase
13 {
14 /**
15 * @dataProvider validationsProvider
16 */
17 public function testRuleValidations($value, $shouldPass)
18 {
19 $rule = new Min(3);
20
21 if ( $shouldPass ) {
22 self::assertValidationRulePassed($rule, $value);
23 } else {
24 self::assertValidationRuleFailed($rule, $value);
25 }
26 }
27
28 public function validationsProvider(): array
29 {
30 return [
31 // numbers
32 [5, true],
33 [3, true],
34 [3.3, true],
35 [2, false],
36 [-10, false],
37
38 // strings
39 ['bob', true],
40 ['bobby', true],
41 ['bo', false],
42 ['', false],
43 ];
44 }
45
46 public function testRuleShouldThrowValidationExceptionForInvalidValue()
47 {
48 $this->expectException(ValidationException::class);
49
50 $rule = new Min(5);
51 self::assertValidationRulePassed($rule, true);
52 }
53
54 public function testRuleThrowsExceptionForNonPositiveSize()
55 {
56 $this->expectException(InvalidArgumentException::class);
57 new Min(0);
58 }
59 }
60