public function testGetsListOfReservationsThatThisUserCanAdminister()
 {
     $user = new User();
     $adminGroup2 = new UserGroup(2, null, 1, RoleLevel::GROUP_ADMIN);
     $adminGroup3 = new UserGroup(3, null, 1, RoleLevel::GROUP_ADMIN);
     $user->WithOwnedGroups(array($adminGroup2, $adminGroup3));
     $reservationRepo = $this->getMock('IReservationViewRepository');
     $reservationAuth = $this->getMock('IReservationAuthorization');
     $userRepo = $this->getMock('IUserRepository');
     $userRepo->expects($this->once())->method('LoadById')->with($this->equalTo($this->fakeUser->UserId))->will($this->returnValue($user));
     $service = new GroupAdminManageReservationsService($reservationRepo, $userRepo, $reservationAuth, $this->getMock('IReservationHandler'), $this->getMock('IUpdateReservationPersistenceService'));
     $reservationRows = FakeReservationRepository::GetReservationRows();
     $this->db->SetRow(0, array(array(ColumnNames::TOTAL => 4)));
     $this->db->SetRow(1, $reservationRows);
     $filter = new ReservationFilter();
     $results = $service->LoadFiltered(1, 2, $filter, $this->fakeUser);
     $getGroupReservationsCommand = new GetFullGroupReservationListCommand(array(2, 3));
     $filterCommand = new FilterCommand($getGroupReservationsCommand, $filter->GetFilter());
     $countCommand = new CountCommand($filterCommand);
     $this->assertEquals($countCommand, $this->db->_Commands[0]);
     $this->assertEquals($filterCommand, $this->db->_Commands[1]);
     $resultList = $results->Results();
     $this->assertEquals(count($reservationRows), count($resultList));
     $this->assertInstanceOf('ReservationItemView', $resultList[0]);
 }
 public function testGetsListOfGroupsThatThisUserCanAdminister()
 {
     $user = new User();
     $adminGroup1 = new UserGroup(1, null, null, RoleLevel::GROUP_ADMIN);
     $adminGroup2 = new UserGroup(2, null, 1, RoleLevel::GROUP_ADMIN);
     $adminGroup3 = new UserGroup(3, null, 1, RoleLevel::GROUP_ADMIN);
     $user->WithOwnedGroups(array($adminGroup1, $adminGroup2, $adminGroup3));
     $userRepo = $this->getMock('IUserRepository');
     $userRepo->expects($this->once())->method('LoadById')->with($this->equalTo($this->fakeUser->UserId))->will($this->returnValue($user));
     $groupRepository = new GroupAdminGroupRepository($userRepo, $this->fakeUser);
     $groupRows = new GroupItemRow();
     $groupRows->With(1, '1');
     $rows = $groupRows->Rows();
     $this->db->SetRow(0, array(array(ColumnNames::TOTAL => 4)));
     $this->db->SetRow(1, $rows);
     $filter = null;
     $results = $groupRepository->GetList(1, 2, null, null, $filter);
     $getGroupsCommand = new GetAllGroupsCommand();
     $filterCommand = new FilterCommand($getGroupsCommand, new SqlFilterIn(new SqlFilterColumn(TableNames::GROUPS_ALIAS, ColumnNames::GROUP_ID), array(1, 2, 3)));
     $countCommand = new CountCommand($filterCommand);
     $this->assertEquals($countCommand, $this->db->_Commands[0]);
     $this->assertEquals($filterCommand, $this->db->_Commands[1]);
     $resultList = $results->Results();
     $this->assertEquals(count($rows), count($resultList));
     $this->assertInstanceOf('GroupItemView', $resultList[0]);
 }
Example #3
0
 public function testIsGroupAdminForGroup()
 {
     $user = new User();
     $user->WithOwnedGroups(array(new UserGroup(1, 'g1'), new UserGroup(2, 'g2')));
     $user->WithGroups(array(new UserGroup(4, 'g4'), new UserGroup(5, 'g5')));
     $this->assertTrue($user->IsGroupAdminFor(1));
     $this->assertTrue($user->IsGroupAdminFor(2));
     $this->assertFalse($user->IsGroupAdminFor(4));
     $this->assertFalse($user->IsGroupAdminFor(5));
 }