Merge pull request #1 from thinkverse/fix-test-seven-and-nine

Fix test seven and nine
This commit is contained in:
PovilasKorop
2021-12-01 19:18:36 +02:00
committed by GitHub
3 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -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()`.
+1
View File
@@ -41,5 +41,6 @@ class User extends Authenticatable
*/
protected $casts = [
'email_verified_at' => 'datetime',
'is_admin' => 'boolean',
];
}
+7 -2
View File
@@ -94,7 +94,7 @@ class ValidationTest extends TestCase
$user = User::where('name', $updatedUser['name'])->first();
$this->assertNotNull($user);
$this->assertEquals(false, $user->is_admin);
$this->assertFalse($user->is_admin);
}
public function test_custom_error_message()
@@ -107,6 +107,11 @@ class ValidationTest extends TestCase
public function test_custom_validation_rule()
{
$response = $this->post('articles', ['title' => 'lowercase']);
$response->assertSessionHasErrors('title')->assertStatus(302);
$response->assertSessionHasErrors([
'title' => 'The title does not start with an uppercased letter',
])->assertStatus(302);
$response = $this->post('articles', ['title' => 'Uppercase']);
$response->assertStatus(200);
}
}