Skip to content

Commit c359ad5

Browse files
committed
Add test with no error
1 parent 8863f7a commit c359ad5

1 file changed

Lines changed: 39 additions & 9 deletions

File tree

tests/system/Validation/ValidationTest.php

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -665,24 +665,25 @@ public function testRulesForArrayField($body, $rules, $results)
665665

666666
//--------------------------------------------------------------------
667667

668-
public function arrayFieldDataProvider() {
668+
public function arrayFieldDataProvider()
669+
{
669670
return [
670671
'all_rules_should_pass' => [
671-
'body' => [
672+
'body' => [
672673
'foo' => [
673674
'a',
674675
'b',
675-
'c'
676-
]
676+
'c',
677+
],
677678
],
678-
'rules' => [
679+
'rules' => [
679680
'foo.0' => 'required|alpha|max_length[2]',
680681
'foo.1' => 'required|alpha|max_length[2]',
681-
'foo.2' => 'required|alpha|max_length[2]'
682+
'foo.2' => 'required|alpha|max_length[2]',
682683
],
683-
'results' => []
684+
'results' => [],
684685
],
685-
'first_field_will_return_required_error' => [
686+
/*'first_field_will_return_required_error' => [
686687
'body' => [
687688
'foo' => [
688689
'',
@@ -716,9 +717,38 @@ public function arrayFieldDataProvider() {
716717
'foo.0' => 'The foo.0 field is required.',
717718
'foo.1' => 'The foo.1 field must be at least 2 characters in length.',
718719
]
719-
]
720+
]*/
720721
];
721722
}
722723

723724
//--------------------------------------------------------------------
725+
726+
public function testRulesForSingleRuleWithAsteriskWillReturnNoError()
727+
{
728+
$config = new App();
729+
$config->baseURL = 'http://example.com';
730+
731+
$_REQUEST = [
732+
'id_user' => [
733+
1,
734+
3,
735+
],
736+
'name_user' => [
737+
'abc123',
738+
'xyz098',
739+
],
740+
];
741+
742+
$request = new IncomingRequest($config, new URI(), 'php://input', new UserAgent());
743+
$request->setMethod('post');
744+
745+
$this->validation->setRules([
746+
'id_user.*' => 'numeric',
747+
'name_user.*' => 'alpha_numeric',
748+
]);
749+
750+
$this->validation->withRequest($request)
751+
->run();
752+
$this->assertEquals([], $this->validation->getErrors());
753+
}
724754
}

0 commit comments

Comments
 (0)