mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-06-05 15:07:56 +09:00
Fix Task 9 - your own validation rule
This commit is contained in:
@@ -98,7 +98,7 @@ Test method `test_custom_error_message()`.
|
||||
|
||||
## Task 9. Your Own Validation Rule.
|
||||
|
||||
In `app/Http/Controllers/ArticleController.php` file, in `store` method, the code uses `Uppercase` validation rule that you need to create with Artisan command, and fill in with the rule of "title" having first letter as uppercase.
|
||||
In `app/Http/Controllers/ArticleController.php` file, in `store` method, the code uses `Uppercase` validation rule that you need to create with Artisan command, and fill in with the rule of "title" having first letter as uppercase with the error message "The title does not start with an uppercased letter".
|
||||
|
||||
Test method `test_custom_validation_rule()`.
|
||||
|
||||
|
||||
@@ -108,7 +108,10 @@ class ValidationTest extends TestCase
|
||||
{
|
||||
$response = $this->post('articles', ['title' => 'lowercase']);
|
||||
$response->assertSessionHasErrors([
|
||||
'title' => 'The title does not start with an uppercased letter.',
|
||||
'title' => 'The title does not start with an uppercased letter',
|
||||
])->assertStatus(302);
|
||||
|
||||
$response = $this->post('articles', ['title' => 'Uppercase']);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user