Skip to content

Commit d8e0d22

Browse files
committed
Add test with errors
1 parent c359ad5 commit d8e0d22

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/system/Validation/ValidationTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,4 +751,38 @@ public function testRulesForSingleRuleWithAsteriskWillReturnNoError()
751751
->run();
752752
$this->assertEquals([], $this->validation->getErrors());
753753
}
754+
755+
//--------------------------------------------------------------------
756+
757+
public function testRulesForSingleRuleWithAsteriskWillReturnError()
758+
{
759+
$config = new App();
760+
$config->baseURL = 'http://example.com';
761+
762+
$_REQUEST = [
763+
'id_user' => [
764+
'1dfd',
765+
3,
766+
],
767+
'name_user' => [
768+
123,
769+
'xyz098',
770+
],
771+
];
772+
773+
$request = new IncomingRequest($config, new URI(), 'php://input', new UserAgent());
774+
$request->setMethod('post');
775+
776+
$this->validation->setRules([
777+
'id_user.*' => 'numeric',
778+
'name_user.*' => 'alpha',
779+
]);
780+
781+
$this->validation->withRequest($request)
782+
->run();
783+
$this->assertEquals([
784+
'id_user.*' => 'The id_user.* field must contain only numbers.',
785+
'name_user.*' => 'The name_user.* field may only contain alphabetical characters.',
786+
], $this->validation->getErrors());
787+
}
754788
}

0 commit comments

Comments
 (0)