Skip to content

Commit 05fbcd4

Browse files
committed
test: add test for feature test with validation twice
1 parent 335ab86 commit 05fbcd4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/system/Test/FeatureTestTraitTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,36 @@ public function testCallPostWithBody()
102102
$response->assertSee('Hello Mars!');
103103
}
104104

105+
public function testCallValidationTwice()
106+
{
107+
$this->withRoutes([
108+
[
109+
'post',
110+
'section/create',
111+
static function () {
112+
$validation = Services::validation();
113+
$validation->setRule('title', 'title', 'required|min_length[3]');
114+
115+
$post = Services::request()->getPost();
116+
117+
if ($validation->run($post)) {
118+
return 'Okay';
119+
}
120+
121+
return 'Invalid';
122+
},
123+
],
124+
]);
125+
126+
$response = $this->post('section/create', ['foo' => 'Mars']);
127+
128+
$response->assertSee('Invalid');
129+
130+
$response = $this->post('section/create', ['title' => 'Section Title']);
131+
132+
$response->assertSee('Okay');
133+
}
134+
105135
public function testCallPut()
106136
{
107137
$this->withRoutes([

0 commit comments

Comments
 (0)