mirror of
https://github.com/10h30/Test-Laravel-Validation.git
synced 2026-07-11 10:55:53 +09:00
Fix Task 7 - update forbidden field
This commit is contained in:
@@ -41,5 +41,6 @@ class User extends Authenticatable
|
|||||||
*/
|
*/
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'email_verified_at' => 'datetime',
|
'email_verified_at' => 'datetime',
|
||||||
|
'is_admin' => 'boolean',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class ValidationTest extends TestCase
|
|||||||
|
|
||||||
$user = User::where('name', $updatedUser['name'])->first();
|
$user = User::where('name', $updatedUser['name'])->first();
|
||||||
$this->assertNotNull($user);
|
$this->assertNotNull($user);
|
||||||
$this->assertEquals(false, $user->is_admin);
|
$this->assertFalse($user->is_admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_custom_error_message()
|
public function test_custom_error_message()
|
||||||
@@ -107,6 +107,8 @@ class ValidationTest extends TestCase
|
|||||||
public function test_custom_validation_rule()
|
public function test_custom_validation_rule()
|
||||||
{
|
{
|
||||||
$response = $this->post('articles', ['title' => 'lowercase']);
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user