/** * @param ItemTreeBounds $itemTreeBounds * @param int $groupId * @return array * @throws Exception */ public function getCurrentClearings(ItemTreeBounds $itemTreeBounds, $groupId, $usageId = LicenseMap::TRIVIAL) { $agentEvents = $this->agentLicenseEventProcessor->getScannerEvents($itemTreeBounds, $usageId); $events = $this->clearingDao->getRelevantClearingEvents($itemTreeBounds, $groupId); $addedResults = array(); $removedResults = array(); foreach (array_unique(array_merge(array_keys($events), array_keys($agentEvents))) as $licenseId) { $licenseDecisionEvent = array_key_exists($licenseId, $events) ? $events[$licenseId] : null; $agentClearingEvents = array_key_exists($licenseId, $agentEvents) ? $agentEvents[$licenseId] : array(); if ($licenseDecisionEvent === null && count($agentClearingEvents) == 0) { throw new Exception('not in merge'); } $licenseDecisionResult = new ClearingResult($licenseDecisionEvent, $agentClearingEvents); if ($licenseDecisionResult->isRemoved()) { $removedResults[$licenseId] = $licenseDecisionResult; } else { $addedResults[$licenseId] = $licenseDecisionResult; } } return array($addedResults, $removedResults); }
public function testIsRemoved() { $this->clearingEvent->shouldReceive("isRemoved")->once()->andReturn(true); $this->licenseDecisionResult = new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1)); assertThat($this->licenseDecisionResult->isRemoved(), is(true)); }