added db asserts
This commit is contained in:
parent
4a2babce94
commit
395ae5dee1
@ -26,16 +26,22 @@ class PermissionsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreatePermission()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('permissions.store'), $this->getRequest())
|
||||
->post(route('permissions.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('permissions', $request);
|
||||
}
|
||||
|
||||
public function testItShouldSeePermissionUpdatePage()
|
||||
{
|
||||
$permission = $this->dispatch(new CreatePermission($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$permission = $this->dispatch(new CreatePermission($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('permissions.edit', $permission->id))
|
||||
@ -57,11 +63,15 @@ class PermissionsTest extends FeatureTestCase
|
||||
->assertSee($request['display_name']);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('permissions', $request);
|
||||
}
|
||||
|
||||
public function testItShouldDeletePermission()
|
||||
{
|
||||
$permission = $this->dispatch(new CreatePermission($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$permission = $this->dispatch(new CreatePermission($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('permissions.destroy', $permission->id))
|
||||
@ -69,6 +79,8 @@ class PermissionsTest extends FeatureTestCase
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseMissing('permissions', $request);
|
||||
|
||||
}
|
||||
|
||||
public function getRequest()
|
||||
|
@ -26,16 +26,22 @@ class RolesTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateRole()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('roles.store'), $this->getRequest())
|
||||
->post(route('roles.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('roles', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function testItShouldSeeRoleUpdatePage()
|
||||
{
|
||||
$role = $this->dispatch(new CreateRole($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$role = $this->dispatch(new CreateRole($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('roles.edit', $role->id))
|
||||
@ -57,21 +63,34 @@ class RolesTest extends FeatureTestCase
|
||||
->assertSee($request['display_name']);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('roles', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function testItShouldDeleteRole()
|
||||
{
|
||||
$role = $this->dispatch(new CreateRole($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$role = $this->dispatch(new CreateRole($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('roles.destroy', $role->id))
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseMissing('roles', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function getRequest()
|
||||
{
|
||||
return factory(Role::class)->states('permissions')->raw();
|
||||
}
|
||||
|
||||
public function getAssertRequest($request)
|
||||
{
|
||||
unset($request['permissions']);
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
|
@ -26,16 +26,22 @@ class UsersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateUser()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('users.store'), $this->getRequest())
|
||||
->post(route('users.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('users', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function testItShouldSeeUserUpdatePage()
|
||||
{
|
||||
$user = $this->dispatch(new CreateUser($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$user = $this->dispatch(new CreateUser($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('users.edit', $user->id))
|
||||
@ -57,17 +63,23 @@ class UsersTest extends FeatureTestCase
|
||||
->assertSee($request['email']);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('users', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function testItShouldDeleteUser()
|
||||
{
|
||||
$user = $this->dispatch(new CreateUser($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$user = $this->dispatch(new CreateUser($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('users.destroy', $user->id))
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertSoftDeleted('users', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function testItShouldSeeLoginPage()
|
||||
@ -79,7 +91,9 @@ class UsersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldLoginUser()
|
||||
{
|
||||
$user = $this->dispatch(new CreateUser($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$user = $this->dispatch(new CreateUser($request));
|
||||
|
||||
$this->post(route('login'), ['email' => $user->email, 'password' => $user->password])
|
||||
->assertStatus(200);
|
||||
@ -89,7 +103,9 @@ class UsersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldNotLoginUser()
|
||||
{
|
||||
$user = $this->dispatch(new CreateUser($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$user = $this->dispatch(new CreateUser($request));
|
||||
|
||||
$this->post(route('login'), ['email' => $user->email, 'password' => $this->faker->password()])
|
||||
->assertStatus(200);
|
||||
@ -99,7 +115,9 @@ class UsersTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldLogoutUser()
|
||||
{
|
||||
$user = $this->dispatch(new CreateUser($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$user = $this->dispatch(new CreateUser($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('logout', $user->id))
|
||||
@ -113,4 +131,15 @@ class UsersTest extends FeatureTestCase
|
||||
{
|
||||
return factory(User::class)->states('enabled')->raw();
|
||||
}
|
||||
|
||||
public function getAssertRequest($request)
|
||||
{
|
||||
unset($request['password']);
|
||||
unset($request['password_confirmation']);
|
||||
unset($request['remember_token']);
|
||||
unset($request['roles']);
|
||||
unset($request['companies']);
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
|
@ -26,16 +26,22 @@ class AccountsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateAccount()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('accounts.store'), $this->getRequest())
|
||||
->post(route('accounts.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('accounts', $request);
|
||||
}
|
||||
|
||||
public function testItShouldSeeAccountUpdatePage()
|
||||
{
|
||||
$account = $this->dispatch(new CreateAccount($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$account = $this->dispatch(new CreateAccount($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('accounts.edit', $account->id))
|
||||
@ -57,17 +63,23 @@ class AccountsTest extends FeatureTestCase
|
||||
->assertSee($request['name']);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('accounts', $request);
|
||||
}
|
||||
|
||||
public function testItShouldDeleteAccount()
|
||||
{
|
||||
$account = $this->dispatch(new CreateAccount($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$account = $this->dispatch(new CreateAccount($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('accounts.destroy', $account->id))
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertSoftDeleted('accounts', $request);
|
||||
}
|
||||
|
||||
public function getRequest()
|
||||
|
@ -25,8 +25,10 @@ class ReconciliationsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateReconciliation()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('reconciliations.store'), $this->getReconciliationRequest())
|
||||
->post(route('reconciliations.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
@ -34,7 +36,9 @@ class ReconciliationsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldSeeReconciliationUpdatePage()
|
||||
{
|
||||
$reconciliation = $this->dispatch(new CreateReconciliation($this->getReconciliationRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$reconciliation = $this->dispatch(new CreateReconciliation($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('reconciliations.edit', $reconciliation->id))
|
||||
@ -44,7 +48,7 @@ class ReconciliationsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldUpdateReconciliation()
|
||||
{
|
||||
$request = $this->getReconciliationRequest();
|
||||
$request = $this->getRequest();
|
||||
|
||||
$reconciliation= $this->dispatch(new CreateReconciliation($request));
|
||||
|
||||
@ -59,7 +63,9 @@ class ReconciliationsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldDeleteReconciliation()
|
||||
{
|
||||
$reconciliation = $this->dispatch(new CreateReconciliation($this->getReconciliationRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$reconciliation = $this->dispatch(new CreateReconciliation($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('reconciliations.destroy', $reconciliation->id))
|
||||
@ -68,7 +74,7 @@ class ReconciliationsTest extends FeatureTestCase
|
||||
$this->assertFlashLevel('success');
|
||||
}
|
||||
|
||||
private function getReconciliationRequest()
|
||||
private function getRequest()
|
||||
{
|
||||
return [
|
||||
'company_id' => $this->company->id,
|
||||
|
@ -34,16 +34,22 @@ class DashboardsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateDashboard()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('dashboards.store'), $this->getRequest())
|
||||
->post(route('dashboards.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('dashboards', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function testItShouldSeeDashboardUpdatePage()
|
||||
{
|
||||
$dashboard = $this->dispatch(new CreateDashboard($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$dashboard = $this->dispatch(new CreateDashboard($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('dashboards.edit', $dashboard->id))
|
||||
@ -65,22 +71,35 @@ class DashboardsTest extends FeatureTestCase
|
||||
->assertSee($request['name']);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('dashboards', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function testItShouldDeleteDashboard()
|
||||
{
|
||||
$dashboard_1 = $this->dispatch(new CreateDashboard($this->getRequest()));
|
||||
$dashboard_2 = $this->dispatch(new CreateDashboard($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$tmp = $this->dispatch(new CreateDashboard($this->getRequest()));
|
||||
$dashboard = $this->dispatch(new CreateDashboard($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('dashboards.destroy', $dashboard_2->id))
|
||||
->delete(route('dashboards.destroy', $dashboard->id))
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertSoftDeleted('dashboards', $this->getAssertRequest($request));
|
||||
}
|
||||
|
||||
public function getRequest()
|
||||
{
|
||||
return factory(Dashboard::class)->states('enabled', 'users')->raw();
|
||||
}
|
||||
|
||||
public function getAssertRequest($request)
|
||||
{
|
||||
unset($request['users']);
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
|
@ -26,16 +26,22 @@ class ItemsTest extends FeatureTestCase
|
||||
|
||||
public function testItShouldCreateItem()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
$this->loginAs()
|
||||
->post(route('items.store'), $this->getRequest())
|
||||
->post(route('items.store'), $request)
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('items', $request);
|
||||
}
|
||||
|
||||
public function testItShouldSeeItemUpdatePage()
|
||||
{
|
||||
$item = $this->dispatch(new CreateItem($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$item = $this->dispatch(new CreateItem($request));
|
||||
|
||||
$this->loginAs()
|
||||
->get(route('items.edit', $item->id))
|
||||
@ -57,17 +63,23 @@ class ItemsTest extends FeatureTestCase
|
||||
->assertSee($request['name']);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertDatabaseHas('items', $request);
|
||||
}
|
||||
|
||||
public function testItShouldDeleteItem()
|
||||
{
|
||||
$item = $this->dispatch(new CreateItem($this->getRequest()));
|
||||
$request = $this->getRequest();
|
||||
|
||||
$item = $this->dispatch(new CreateItem($request));
|
||||
|
||||
$this->loginAs()
|
||||
->delete(route('items.destroy', $item->id))
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertFlashLevel('success');
|
||||
|
||||
$this->assertSoftDeleted('items', $request);
|
||||
}
|
||||
|
||||
public function getRequest()
|
||||
|
Loading…
x
Reference in New Issue
Block a user