public function testCanGetQuotas() { $limit = 12; $resourceId = 100; $groupId = 923; $scheduleId = 828; $rows[] = $this->GetRow(1, $limit, QuotaUnit::Reservations, QuotaDuration::Month, $resourceId, $groupId, $scheduleId); $rows[] = $this->GetRow(2, $limit, QuotaUnit::Hours, QuotaDuration::Day, null, null, null); $rows[] = $this->GetRow(3, $limit, QuotaUnit::Hours, QuotaDuration::Week, null, $groupId, $scheduleId); $this->db->SetRows($rows); /** @var $quotas Quota[] */ $quotas = $this->repository->LoadAll(); $quota1 = $quotas[0]; $quota2 = $quotas[1]; $quota3 = $quotas[2]; $command = new GetAllQuotasCommand(); $this->assertEquals($command, $this->db->_LastCommand); $this->assertEquals(new QuotaLimitCount($limit), $quota1->GetLimit()); $this->assertEquals(new QuotaLimitHours($limit), $quota2->GetLimit()); $this->assertEquals(new QuotaLimitHours($limit), $quota3->GetLimit()); $this->assertEquals(new QuotaDurationMonth(), $quota1->GetDuration()); $this->assertEquals(new QuotaDurationDay(), $quota2->GetDuration()); $this->assertEquals(new QuotaDurationWeek(), $quota3->GetDuration()); $this->assertTrue($quota1->AppliesToResource($resourceId)); $this->assertTrue($quota1->AppliesToGroup($groupId)); $this->assertTrue($quota1->AppliesToSchedule($scheduleId)); $this->assertFalse($quota1->AppliesToResource(727)); $this->assertFalse($quota1->AppliesToGroup(727)); $this->assertFalse($quota1->AppliesToSchedule(727)); $this->assertTrue($quota2->AppliesToResource(89123987)); $this->assertTrue($quota2->AppliesToGroup(128973)); $this->assertTrue($quota2->AppliesToSchedule($scheduleId)); $this->assertTrue($quota3->AppliesToResource(89123987)); $this->assertTrue($quota3->AppliesToGroup($groupId)); $this->assertFalse($quota3->AppliesToSchedule(18)); }