public function testOnlyGetsSchedulesWhereUserIsAdmin()
 {
     $user = $this->getMock('User');
     $this->userRepository->expects($this->once())->method('LoadById')->with($this->equalTo($this->fakeUser->UserId))->will($this->returnValue($user));
     $ra = new FakeScheduleRepository();
     $this->db->SetRows($ra->GetRows());
     $user->expects($this->at(0))->method('IsScheduleAdminFor')->with($this->equalTo($ra->_AllRows[0]))->will($this->returnValue(false));
     $user->expects($this->at(1))->method('IsScheduleAdminFor')->with($this->equalTo($ra->_AllRows[1]))->will($this->returnValue(true));
     $schedules = $this->repo->GetAll();
     $this->assertTrue($this->db->ContainsCommand(new GetAllSchedulesCommand()));
     $this->assertEquals(1, count($schedules));
     $this->assertEquals(2, $schedules[0]->GetId());
 }
Example #2
0
 public static function Initialize()
 {
     self::$Schedule1 = new Schedule(1, "schedule 1", true, '09:00', '20:00', 0, 1, 5);
 }
 public function testCanAddNewSchedule()
 {
     $layoutId = 87;
     $name = 'new dude';
     $isDefault = false;
     $weekdayStart = 2;
     $daysVisible = 5;
     $scheduleIdOfSourceLayout = 981;
     $schedule = new Schedule(null, $name, $isDefault, $weekdayStart, $daysVisible, null, $layoutId);
     $expectedGetScheduleById = new GetScheduleByIdCommand($scheduleIdOfSourceLayout);
     $fakeSchedules = new FakeScheduleRepository();
     $this->db->SetRows(array($fakeSchedules->GetRow(9, null, true, 0, 0, null, $layoutId)));
     $expectedInsertScheduleCommand = new AddScheduleCommand($name, $isDefault, $weekdayStart, $daysVisible, $layoutId);
     $this->scheduleRepository->Add($schedule, $scheduleIdOfSourceLayout);
     $this->assertTrue($this->db->ContainsCommand($expectedGetScheduleById));
     $this->assertTrue($this->db->ContainsCommand($expectedInsertScheduleCommand));
 }