상속: extends Illuminate\Foundation\Auth\User, use trait Illuminate\Database\Eloquent\SoftDeletes, use trait Zizaco\Entrust\Traits\EntrustUserTrait
 public function test_a_boss_can_access_admin()
 {
     $admin = User::find(3);
     $this->be($admin);
     $response = $this->call('GET', URL::to('/admin/'));
     $this->assertEquals('200', $response->getStatusCode());
 }
예제 #2
0
 public function test_can_register_success()
 {
     $this->addValidator();
     $this->post('/auth/register', ['username' => 'learner', 'email' => '*****@*****.**', 'password' => '121212', 'password_confirmation' => '121212']);
     $user = User::find(1);
     $this->assertEquals($user->email, '*****@*****.**');
     $this->assertTrue(Hash::check('121212', $user->password));
 }
예제 #3
0
 /**
  * attach a role to user.
  *
  * @param \Learner\Models\User $user
  * @param  mixed $roleOrRoleId
  */
 public function attachRole(User $user, $roleOrRoleId)
 {
     $user->roles()->attach($roleOrRoleId);
 }
예제 #4
0
 /**
  * Create a new user.
  *
  * @return \Learner\Models\User
  */
 protected function createAUser()
 {
     $args = func_get_args();
     $newUser = User::create(['username' => $args[0], 'nickname' => $args[1], 'email' => $args[2], 'avatar' => $args[3]]);
     $userRole = Role::whereName('user')->first();
     $newUser->roles()->attach($userRole);
     return $newUser;
 }
예제 #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $people = ['username' => 'boss', 'email' => '*****@*****.**', 'password' => '121212'];
     $user = User::create(['username' => $people['username'], 'email' => $people['email'], 'password' => Hash::make($people['password']), 'avatar' => AvatarManager::generateAvatar($people['username'])]);
     $user->roles()->attach(3);
 }