Skip to content

Commit ca9d244

Browse files
committed
test: add test case
1 parent 0d775ac commit ca9d244

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

tests/system/Validation/StrictRules/ValidationTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,23 @@ public function testRunReturnsLocalizedErrors(): void
202202

203203
public function testRunWithCustomErrors(): void
204204
{
205-
$data = ['foo' => 'notanumber'];
206-
205+
$data = [
206+
'foo' => 'notanumber',
207+
'bar' => 'notanumber',
208+
];
207209
$messages = [
208210
'foo' => [
209211
'is_numeric' => 'Nope. Not a number.',
210212
],
213+
'bar' => [
214+
'is_numeric' => 'No. Not a number.',
215+
],
211216
];
212-
213-
$this->validation->setRules(['foo' => 'is_numeric'], $messages);
217+
$this->validation->setRules(['foo' => 'is_numeric', 'bar' => 'is_numeric'], $messages);
214218
$this->validation->run($data);
219+
215220
$this->assertSame('Nope. Not a number.', $this->validation->getError('foo'));
221+
$this->assertSame('No. Not a number.', $this->validation->getError('bar'));
216222
}
217223

218224
public function testCheck(): void

tests/system/Validation/ValidationTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,23 @@ public function testRunReturnsLocalizedErrors(): void
305305

306306
public function testRunWithCustomErrors(): void
307307
{
308-
$data = ['foo' => 'notanumber'];
309-
308+
$data = [
309+
'foo' => 'notanumber',
310+
'bar' => 'notanumber',
311+
];
310312
$messages = [
311313
'foo' => [
312314
'is_numeric' => 'Nope. Not a number.',
313315
],
316+
'bar' => [
317+
'is_numeric' => 'No. Not a number.',
318+
],
314319
];
315-
316-
$this->validation->setRules(['foo' => 'is_numeric'], $messages);
320+
$this->validation->setRules(['foo' => 'is_numeric', 'bar' => 'is_numeric'], $messages);
317321
$this->validation->run($data);
322+
318323
$this->assertSame('Nope. Not a number.', $this->validation->getError('foo'));
324+
$this->assertSame('No. Not a number.', $this->validation->getError('bar'));
319325
}
320326

321327
public function testCheck(): void

0 commit comments

Comments
 (0)