public function test_can_create_role() { $this->createUser(); $this->createRoles(); $this->assertCount(3, $this->app->make(RoleRepositoryInterface::class)->all()); $this->app->make(UserRepositoryInterface::class)->addRoles(1, [1, 2, 3]); $this->assertCount(3, User::find(1)->roles); $this->assertCount(1, Role::find(1)->users); $this->assertTrue(User::find(1)->isAdmin()); }
public function test_can_restore_rows_from_deleted() { $user = User::create(['name' => 'User Test', 'email' => '*****@*****.**', 'password' => '123456']); $user->delete(); $user->restore(); $user = User::find(1); $this->assertEquals(1, $user->id); $this->assertEquals('User Test', $user->name); }
/** * Run the migrations. * * @return void */ public function up() { $roleAdmin = Role::where('name', Role::ROLE_ADMIN)->first(); $admin = User::create(['name' => 'Administrator', 'email' => '*****@*****.**', 'password' => bcrypt(123456)]); $admin->roles()->save($roleAdmin); }
protected function getUser() { return User::all()->first(); }
/** * 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'])]); }