/** * Run the database seeds. * * Create one user for every role * * @return void */ public function run() { $roles = \App\Role::getAllSystemRoles(); //$this->seedOnlyOwner(); foreach ($roles as $role) { $ucfRole = ucfirst($role); $u = factory(App\User::class, $role)->create(['name' => $ucfRole, 'email' => $role . '@' . $role . '.dev', 'password' => bcrypt($role)]); $u->companies()->save(factory(App\Company::class, 1)->make(['name' => $ucfRole . '\'s Company'])); } }
public function test_every_user_role_can_see_any_company_details() { // create owner with company $owner = factory(User::class, 'owner')->create(); $owner->companies()->save($company = factory(Company::class)->create()); $roles = Role::getAllSystemRoles(); foreach ($roles as $role) { $user = factory(User::class, $role)->create(); $this->actingAs($user)->get('/company/' . $company->id)->assertResponseStatus(200); } }