public function testGetScreenPermissions() { $userRole = new UserRole(); $userRole->setId(1); $userRole->setName('Admin'); $user = new SystemUser(); $user->setId(1); $user->setEmpNumber(NULL); $user->setUserRole($userRole); $systemUserService = $this->getMock('SystemUserService', array('getSystemUser')); $systemUserService->expects($this->once())->method('getSystemUser')->with($user->getId())->will($this->returnValue($user)); $this->manager->setSystemUserService($systemUserService); $this->manager->setUser($user); $mockScreenPermissionService = $this->getMock('ScreenPermissionService', array('getScreenPermissions')); $permission = new ResourcePermission(true, false, true, false); $module = 'admin'; $action = 'testAction'; $roles = array($userRole); $mockScreenPermissionService->expects($this->once())->method('getScreenPermissions')->with($module, $action, $roles)->will($this->returnValue($permission)); $this->manager->setScreenPermissionService($mockScreenPermissionService); $result = $this->manager->getScreenPermissions($module, $action); $this->assertEquals($permission, $result); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param SystemUser $value A SystemUser object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(SystemUser $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * * @param Users $user * @deprecated */ protected function setBasicUserAttributesToSession(SystemUser $user) { $_SESSION['user'] = $user->getId(); $_SESSION['userGroup'] = $user->getUsergId(); $_SESSION['isAdmin'] = $user->getIsAdmin(); /* In the base product, this session variable is assigned with the value employee number (emp_number field), left padded with zeros. The session variable does not contain the value of actual employee id (employee_id field) */ $padLength = 4; // This should be taken from sysConf of the base product $_SESSION['empID'] = str_pad($user->getEmployee()->getEmpNumber(), $padLength, '0', STR_PAD_LEFT); $_SESSION['empNumber'] = $user->getEmpNumber(); $_SESSION['fname'] = $user->getName(); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param SystemUser $value A SystemUser object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(SystemUser $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } if (isset(self::$instances[$key]) || count(self::$instances) < kConf::get('max_num_instances_in_pool')) { self::$instances[$key] = $obj; kMemoryManager::registerPeer('SystemUserPeer'); } } }