mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
test: add test for feature test with validation twice
This commit is contained in:
parent
335ab860b6
commit
05fbcd4a2a
@ -102,6 +102,36 @@ final class FeatureTestTraitTest extends CIUnitTestCase
|
||||
$response->assertSee('Hello Mars!');
|
||||
}
|
||||
|
||||
public function testCallValidationTwice()
|
||||
{
|
||||
$this->withRoutes([
|
||||
[
|
||||
'post',
|
||||
'section/create',
|
||||
static function () {
|
||||
$validation = Services::validation();
|
||||
$validation->setRule('title', 'title', 'required|min_length[3]');
|
||||
|
||||
$post = Services::request()->getPost();
|
||||
|
||||
if ($validation->run($post)) {
|
||||
return 'Okay';
|
||||
}
|
||||
|
||||
return 'Invalid';
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
$response = $this->post('section/create', ['foo' => 'Mars']);
|
||||
|
||||
$response->assertSee('Invalid');
|
||||
|
||||
$response = $this->post('section/create', ['title' => 'Section Title']);
|
||||
|
||||
$response->assertSee('Okay');
|
||||
}
|
||||
|
||||
public function testCallPut()
|
||||
{
|
||||
$this->withRoutes([
|
||||
|
Loading…
x
Reference in New Issue
Block a user