| @@ 51-67 (lines=17) @@ | ||
| 48 | /** |
|
| 49 | * Test assert method. |
|
| 50 | */ |
|
| 51 | public function testAssertExplicitConstraints() |
|
| 52 | { |
|
| 53 | $this |
|
| 54 | ->given($validator = $this->creaateValidator()) |
|
| 55 | ->then() |
|
| 56 | ->boolean($validator->assert('ivannis', Assert::alnum()->noWhitespace()->length(1, 15))) |
|
| 57 | ->isTrue() |
|
| 58 | ->boolean($validator->assert('ivannis', Assert::alnum()->noWhitespace()->length(1, 15), 'foo')) |
|
| 59 | ->isTrue() |
|
| 60 | ->exception(function () use ($validator) { |
|
| 61 | $validator->assert('some tests', Assert::alnum()->noWhitespace()->length(1, 15)); |
|
| 62 | })->isInstanceOf(ValidationException::class) |
|
| 63 | ->exception(function () use ($validator) { |
|
| 64 | $validator->assert('value'); |
|
| 65 | })->isInstanceOf(\RuntimeException::class) |
|
| 66 | ; |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * Test assert method. |
|
| @@ 134-149 (lines=16) @@ | ||
| 131 | /** |
|
| 132 | * Test validate method. |
|
| 133 | */ |
|
| 134 | public function testValidateExplicitConstraints() |
|
| 135 | { |
|
| 136 | $this |
|
| 137 | ->given($validator = $this->creaateValidator()) |
|
| 138 | ->then() |
|
| 139 | ->boolean($validator->validate('ivannis', Assert::alnum()->noWhitespace()->length(1, 15))) |
|
| 140 | ->isTrue() |
|
| 141 | ->boolean($validator->validate('ivannis', Assert::alnum()->noWhitespace()->length(1, 15), 'foo')) |
|
| 142 | ->isTrue() |
|
| 143 | ->boolean($validator->validate('some tests', Assert::alnum()->noWhitespace()->length(1, 15))) |
|
| 144 | ->isFalse() |
|
| 145 | ->exception(function () use ($validator) { |
|
| 146 | $validator->validate('value'); |
|
| 147 | })->isInstanceOf(\RuntimeException::class) |
|
| 148 | ; |
|
| 149 | } |
|
| 150 | ||
| 151 | /** |
|
| 152 | * Test validate method. |
|