|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Shergela\Validations; |
| 4 | + |
| 5 | + |
| 6 | +use App\Enums\TestEnum; |
| 7 | +use Shergela\Validations\Validation\Rule; |
| 8 | +use Tests\TestCase; |
| 9 | + |
| 10 | +class RuleNotInTest extends TestCase |
| 11 | +{ |
| 12 | + public function test_not_in_validation() |
| 13 | + { |
| 14 | + $rule = Rule::notIn(['Caldera', 'Aramis', 'Athos'])->getRule(1); |
| 15 | + |
| 16 | + $this->assertSame('not_in:"Caldera","Aramis","Athos"', (string) $rule); |
| 17 | + |
| 18 | + $rule = Rule::notIn(collect(['Taylor', 'Michael', 'Tim']))->getRule(1); |
| 19 | + |
| 20 | + $this->assertSame('not_in:"Taylor","Michael","Tim"', (string) $rule); |
| 21 | + |
| 22 | + $rule = Rule::notIn(['Life, the Universe and Everything', 'this is a "quote"'])->getRule(1); |
| 23 | + |
| 24 | + $this->assertSame('not_in:"Life, the Universe and Everything","this is a ""quote"""', (string) $rule); |
| 25 | + |
| 26 | + $rule = Rule::notIn(collect([1, 2, 3, 4]))->getRule(1); |
| 27 | + |
| 28 | + $this->assertSame('not_in:"1","2","3","4"', (string) $rule); |
| 29 | + |
| 30 | + $rule = Rule::notIn(collect([1, 2, 3, 4]))->getRule(1); |
| 31 | + |
| 32 | + $this->assertSame('not_in:"1","2","3","4"', (string) $rule); |
| 33 | + |
| 34 | + $rule = Rule::notIn(["a,b\nc,d"])->getRule(1); |
| 35 | + |
| 36 | + $this->assertSame("not_in:\"a,b\nc,d\"", (string) $rule); |
| 37 | + |
| 38 | + $rule = Rule::notIn([1, 2, 3, 4])->getRule(1); |
| 39 | + |
| 40 | + $this->assertSame('not_in:"1","2","3","4"', (string) $rule); |
| 41 | + |
| 42 | + $rule = Rule::notIn(collect([1, 2, 3, 4]))->getRule(1); |
| 43 | + |
| 44 | + $this->assertSame('not_in:"1","2","3","4"', (string) $rule); |
| 45 | + |
| 46 | + $rule = Rule::notIn('1', '2', '3', '4')->getRule(1); |
| 47 | + |
| 48 | + $this->assertSame('not_in:"1","2","3","4"', (string) $rule); |
| 49 | + |
| 50 | + $rule = Rule::notIn('1', '2', '3', '4')->getRule(1); |
| 51 | + |
| 52 | + $this->assertSame('not_in:"1","2","3","4"', (string) $rule); |
| 53 | + |
| 54 | + $rule = Rule::notIn([TestEnum::ONE])->getRule(1); |
| 55 | + |
| 56 | + $this->assertSame('not_in:"1"', (string) $rule); |
| 57 | + |
| 58 | + $rule = Rule::notIn([TestEnum::TWO])->getRule(1); |
| 59 | + |
| 60 | + $this->assertSame('not_in:"2"', (string) $rule); |
| 61 | + |
| 62 | + $rule = Rule::notIn([TestEnum::STRING_ONE])->getRule(1); |
| 63 | + |
| 64 | + $this->assertSame('not_in:"one"', (string) $rule); |
| 65 | + } |
| 66 | +} |
0 commit comments