Commit 02641fb5 authored by Viral Solani's avatar Viral Solani

Test case for create_user_fails_if_email_is_exists

parent 8db1fd5f
...@@ -13,6 +13,22 @@ use App\Notifications\Frontend\Auth\UserNeedsConfirmation; ...@@ -13,6 +13,22 @@ use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
class ManageUsersTest extends TestCase class ManageUsersTest extends TestCase
{ {
/**
* 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);
}
/** @test */ /** @test */
public function a_user_can_view_active_users() public function a_user_can_view_active_users()
{ {
...@@ -121,6 +137,13 @@ class ManageUsersTest extends TestCase ...@@ -121,6 +137,13 @@ class ManageUsersTest extends TestCase
->assertSessionHasErrors('permissions'); ->assertSessionHasErrors('permissions');
} }
/** @test */
public function create_user_fails_if_email_is_exists()
{
$this->createUser(['email' => 'admin@admin.com'])
->assertSessionHasErrors('email');
}
/** @test */ /** @test */
public function a_user_can_create_new_user() public function a_user_can_create_new_user()
{ {
...@@ -199,19 +222,10 @@ class ManageUsersTest extends TestCase ...@@ -199,19 +222,10 @@ class ManageUsersTest extends TestCase
Event::assertDispatched(UserCreated::class); Event::assertDispatched(UserCreated::class);
} }
/** //@todo
* Create User. // update user
* // delete user
* @param $overrides // user can not delete himself
* // change password
* @return [array] User array // export / import feature
*/
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