Commit 18250270 authored by Viral Solani's avatar Viral Solani

Validation Test Case for User

parent 813feb99
...@@ -59,6 +59,48 @@ class ManageUsersTest extends TestCase ...@@ -59,6 +59,48 @@ class ManageUsersTest extends TestCase
->assertSee($this->admin->email); ->assertSee($this->admin->email);
} }
/** @test */
function a_user_requires_a_first_name()
{
$this->createUser(['first_name' => null])
->assertSessionHasErrors('first_name');
}
/** @test */
function a_user_requires_a_last_name()
{
$this->createUser(['last_name' => null])
->assertSessionHasErrors('last_name');
}
/** @test */
function a_user_requires_a_email()
{
$this->createUser(['email' => null])
->assertSessionHasErrors('email');
}
/** @test */
function a_user_requires_a_password()
{
$this->createUser(['password' => null])
->assertSessionHasErrors('password');
}
/** @test */
function a_user_requires_a_role()
{
$this->createUser()
->assertSessionHasErrors('assignees_roles');
}
/** @test */
function a_user_requires_a_permission()
{
$this->createUser()
->assertSessionHasErrors('permissions');
}
/** @test */ /** @test */
public function a_user_can_create_new_user() public function a_user_can_create_new_user()
{ {
...@@ -79,4 +121,19 @@ class ManageUsersTest extends TestCase ...@@ -79,4 +121,19 @@ class ManageUsersTest extends TestCase
$this->assertDatabaseHas('roles', ['name' => $role->name]); $this->assertDatabaseHas('roles', ['name' => $role->name]);
$this->assertDatabaseHas('permissions', ['name' => $permission->name]); $this->assertDatabaseHas('permissions', ['name' => $permission->name]);
} }
/**
* Create User
*
* @param $overrides
* @return [array] User array
*/
protected function createUser($overrides = [])
{
$user = factory(User::class, $overrides = [])->states('active', 'confirmed')->make()->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.user.store'), $user);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment