@@ 83-99 (lines=17) @@ | ||
80 | /** |
|
81 | * Test assert method. |
|
82 | */ |
|
83 | public function testAssertExplicitConstraints() |
|
84 | { |
|
85 | $this |
|
86 | ->given($validator = $this->creaateValidator()) |
|
87 | ->then() |
|
88 | ->boolean($validator->assert('ivannis', Assert::alnum()->noWhitespace()->length(1, 15))) |
|
89 | ->isTrue() |
|
90 | ->boolean($validator->assert('ivannis', Assert::alnum()->noWhitespace()->length(1, 15), 'foo')) |
|
91 | ->isTrue() |
|
92 | ->exception(function () use ($validator) { |
|
93 | $validator->assert('some tests', Assert::alnum()->noWhitespace()->length(1, 15)); |
|
94 | })->isInstanceOf(ValidationException::class) |
|
95 | ->exception(function () use ($validator) { |
|
96 | $validator->assert('value'); |
|
97 | })->isInstanceOf(\RuntimeException::class) |
|
98 | ; |
|
99 | } |
|
100 | ||
101 | /** |
|
102 | * Test assert method. |
|
@@ 166-181 (lines=16) @@ | ||
163 | /** |
|
164 | * Test validate method. |
|
165 | */ |
|
166 | public function testValidateExplicitConstraints() |
|
167 | { |
|
168 | $this |
|
169 | ->given($validator = $this->creaateValidator()) |
|
170 | ->then() |
|
171 | ->boolean($validator->validate('ivannis', Assert::alnum()->noWhitespace()->length(1, 15))) |
|
172 | ->isTrue() |
|
173 | ->boolean($validator->validate('ivannis', Assert::alnum()->noWhitespace()->length(1, 15), 'foo')) |
|
174 | ->isTrue() |
|
175 | ->boolean($validator->validate('some tests', Assert::alnum()->noWhitespace()->length(1, 15))) |
|
176 | ->isFalse() |
|
177 | ->exception(function () use ($validator) { |
|
178 | $validator->validate('value'); |
|
179 | })->isInstanceOf(\RuntimeException::class) |
|
180 | ; |
|
181 | } |
|
182 | ||
183 | /** |
|
184 | * Test validate method. |