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 / InStrictTest.php

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

77 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Vendors\StellarWP\Validation\Tests\Unit\Rules;
4
5 use InvalidArgumentException;
6 use Give\Vendors\StellarWP\Validation\Rules\InStrict;
7 use Give\Vendors\StellarWP\Validation\Tests\TestCase;
8
9 class InStrictTest extends TestCase
10 {
11 /**
12 * @since 1.2.0
13 */
14 public function testShouldAllowStrictlyEqualValuesInArray()
15 {
16 $rule = new InStrict('foo', 1);
17
18 $this->assertValidationRulePassed($rule, 'foo');
19 $this->assertValidationRulePassed($rule, 1);
20 }
21
22 /**
23 * @since 1.2.0
24 */
25 public function testShouldFailStrictlyUnequalValues()
26 {
27 $rule = new InStrict('foo', 1);
28
29 $this->assertValidationRuleFailed($rule, '1');
30 $this->assertValidationRuleFailed($rule, 'bar');
31 $this->assertValidationRuleFailed($rule, 2);
32 $this->assertValidationRuleFailed($rule, false);
33 }
34
35 /**
36 * @since 1.2.0
37 */
38 public function testShouldCreateRuleFromCommaDelimitedList()
39 {
40 $rule = InStrict::fromString('foo,1');
41
42 $this->assertValidationRulePassed($rule, 'foo');
43 $this->assertValidationRulePassed($rule, '1');
44 $this->assertValidationRuleFailed($rule, 1);
45 $this->assertValidationRuleFailed($rule, 'qux');
46 }
47
48 /**
49 * @since 1.2.0
50 */
51 public function testFromStringShouldRequireValues()
52 {
53 $this->expectException(InvalidArgumentException::class);
54
55 InStrict::fromString('');
56 }
57
58 /**
59 * @since 1.2.0
60 */
61 public function testShouldThrowInvalidExceptionWithoutValues()
62 {
63 $this->expectException(InvalidArgumentException::class);
64
65 new InStrict();
66 }
67
68 /**
69 * @since 1.2.0
70 */
71 public function testSerializeOptionShouldRetunValuesArray()
72 {
73 $rule = new InStrict('foo', 'bar', 'baz');
74 $this->assertEquals(['foo', 'bar', 'baz'], $rule->serializeOption());
75 }
76 }
77