예제 #1
0
 /**
  * Test save
  */
 public function testSave()
 {
     $role = new Phprojekt_Role_Role();
     $role->name = '';
     $this->assertFalse($role->recordValidate());
     $this->assertNotEquals(array(), $role->getError());
     $role->name = 'New Role';
     $role->save();
     $role->saveRights(array('1' => 139));
     $this->assertEquals(1, count($role->modulePermissions->fetchAll()));
     $role->saveRights(array(1 => 139, 2 => 139));
     $this->assertEquals(2, count($role->modulePermissions->fetchAll()));
     $role->delete();
 }
예제 #2
0
 public function testDeleteHasManyAndBelongsToMany()
 {
     $authNamespace = new Zend_Session_Namespace('Phprojekt_Auth-login');
     $keepUser = $authNamespace->userId;
     $role = new Phprojekt_Role_Role(array('db' => $this->sharedFixture));
     $role->name = 'deleteMe';
     $role->save();
     $modulePermissions = $role->modulePermissions->create();
     $modulePermissions->moduleId = 1;
     $modulePermissions->roleId = $role->id;
     $modulePermissions->access = 199;
     $this->assertTrue($modulePermissions->save());
     $this->assertNotNull($role->id);
     $this->assertEquals(2, $role->modulePermissions->count());
     $role->delete();
     $this->assertEquals(1, $role->modulePermissions->count());
     $this->assertNull($role->id);
     $authNamespace->userId = $keepUser;
 }