Ejemplo n.º 1
0
 /**
  * Returns a user group created using an array with user group data.
  *
  * @param  mixed[]    $groupRow
  * @return GroupModel
  */
 public function loadFromArray($groupRow = array())
 {
     $group = new GroupModel();
     if (isset($groupRow['id'])) {
         $group->setId($groupRow['id']);
     }
     if (isset($groupRow['name'])) {
         $group->setName($groupRow['name']);
     }
     return $group;
 }
Ejemplo n.º 2
0
 /**
  * Tests if the user group can save and return a name.
  */
 public function testName()
 {
     $group = new Group();
     $group->setName('newGroup');
     $this->assertEquals('newGroup', $group->getName(), 'The group name did not save correctly.');
 }
Ejemplo n.º 3
0
 /**
  * Tests if the access for a user can be returned.
  */
 public function testHasAccess()
 {
     $group = new Group();
     $group->setId(3);
     $group->setName('Testgroup');
     $user = new User();
     $user->setId(123);
     $user->addGroup($group);
     $dbMock = $this->getMock('Ilch_Database', array('queryCell'));
     $dbMock->expects($this->once())->method('queryCell')->with($this->logicalAnd($this->stringContains('FROM [prefix]_groups_access'), $this->stringContains('INNER JOIN `[prefix]_modules`'), $this->stringContains('user')))->will($this->returnValue('0'));
     Registry::remove('db');
     Registry::set('db', $dbMock);
     $this->assertEquals(0, $user->hasAccess('module_user'));
 }