public function testFilterCurrentReusableClearingDecisions() { $itemId = 543; $itemId2 = 432; $decision1 = M::mock(ClearingDecision::classname()); $decision1->shouldReceive("getUploadTreeId")->andReturn($itemId); $decision2 = M::mock(ClearingDecision::classname()); $decision2->shouldReceive("getUploadTreeId")->andReturn($itemId2); $filteredClearingDecisions = $this->clearingDecisionFilter->filterCurrentReusableClearingDecisions(array($decision1, $decision2)); $expecedArray = array($itemId => $decision1, $itemId2 => $decision2); assertThat($filteredClearingDecisions, containsInAnyOrder($expecedArray)); }
/** * @brief user decides no license, then scanner finds licA, than user removes licA -> no new clearing event should be generated as nothing changes the state */ public function testMakeDecisionFromLastEventsWithDelayedScanner() { /** @var LicenseRef $licenseRef */ list($scannerResults, $licenseRef) = $this->createScannerDetectedLicenses(); $isGlobal = false; $removedEvent = $this->createClearingEvent(123, $this->timestamp, $licenseRef->getId(), $licenseRef->getShortName(), $licenseRef->getFullName(), ClearingEventTypes::USER, $isRemoved = true); $this->clearingDao->shouldReceive("getRelevantClearingEvents")->with($this->itemTreeBounds, $this->groupId)->andReturn(array($licenseRef->getId() => $removedEvent)); $this->agentLicenseEventProcessor->shouldReceive("getScannerEvents")->with($this->itemTreeBounds)->andReturn($scannerResults); $clearingDecision = M::mock(ClearingDecision::classname()); $clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp - 3600); $clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED); $clearingDecision->shouldReceive("getClearingEvents")->withNoArgs()->andReturn(array()); $this->clearingDao->shouldReceive("getRelevantClearingDecision")->with($this->itemTreeBounds, $this->groupId)->andReturn($clearingDecision); $this->clearingDao->shouldReceive("insertClearingEvent")->never(); $this->clearingDao->shouldReceive("createDecisionFromEvents")->once()->with($this->uploadTreeId, $this->userId, $this->groupId, DecisionTypes::IDENTIFIED, DecisionScopes::ITEM, is(arrayContainingInAnyOrder($removedEvent->getEventId()))); $this->clearingDao->shouldReceive("removeWipClearingDecision")->never(); $this->clearingDecisionProcessor->makeDecisionFromLastEvents($this->itemTreeBounds, $this->userId, $this->groupId, DecisionTypes::IDENTIFIED, $isGlobal); }