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')); }
/** * 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); }
/** * 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); }