Ejemplo n.º 1
0
 public function testEntrustHasRole()
 {
     // Current user
     $user = m::mock('User');
     // Permission manage a as true
     $user->shouldReceive('hasRole')->with('AdminA')->once()->andReturn(true);
     // Permission manage b as false
     $user->shouldReceive('hasRole')->with('AdminB')->once()->andReturn(false);
     $entrust = new Entrust($this->mockAppWithCurrentUser($user));
     // Check if user 'can'
     $this->assertTrue($entrust->hasRole('AdminA'));
     $this->assertFalse($entrust->hasRole('AdminB'));
 }
Ejemplo n.º 2
0
 /**
  * Checks if the current user has a Role by its name
  *
  * @param string $name Role name.
  * @return bool 
  * @static 
  */
 public static function hasRole($permission)
 {
     return \Zizaco\Entrust\Entrust::hasRole($permission);
 }
Ejemplo n.º 3
0
 /**
  * Checks if the current user has a role by its name
  *
  * @param string $name Role name.
  * @return bool 
  * @static 
  */
 public static function hasRole($role, $requireAll = false)
 {
     return \Zizaco\Entrust\Entrust::hasRole($role, $requireAll);
 }