/** @test */ public function it_adds_all_users_to_member_role() { $this->prepare(); $user = User::create(['name' => 'Test User', 'email' => '*****@*****.**', 'password' => 'test1234']); $this->assignment->addAllUsersToMemberRole(); $user->load('roles'); $this->assertTrue($user->roles->contains('Member')); }
public function prepare() { Session::start(); $this->artisan('migrate', ['--path' => 'packages/genealabs/laravel-governor/database/migrations']); $this->artisan('migrate', ['--path' => 'database/secondaryMigrations']); $this->superAdminUser = factory(LaravelGovernorTests\User::class)->create(); $this->artisan('db:seed', ['--class' => 'LaravelGovernorDatabaseSeeder']); $this->unauthorizedUser = factory(LaravelGovernorTests\User::class)->create(); $this->superAdminUser->fill(['name' => 'Test User', 'first_name' => 'Test', 'last_name' => 'User', 'email' => '*****@*****.**', 'password' => 'test123$']); $this->superAdminUser->save(); $this->rolePolicy = new RolePolicy(); $this->entityPolicy = new EntityPolicy(); $this->assignmentPolicy = new AssignmentPolicy(); $this->superAdminRole = Role::find('SuperAdmin'); $this->memberRole = Role::find('Member'); $this->role = new Role(); $this->entity = new Entity(); $this->assignment = new Assignment(); $this->memberUser = User::limit(2)->get()->last(); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); }