30 private $clearingDecisionFilter;
32 protected function setUp()
37 protected function tearDown()
42 public function testFilterCurrentClearingDecisions()
46 $decision1 = M::mock(ClearingDecision::class);
47 $decision1->shouldReceive(
"getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
48 $decision1->shouldReceive(
"getScope")->atLeast()->once()->withNoArgs()->andReturn(DecisionScopes::REPO);
49 $decision1->shouldReceive(
"getUploadTreeId")->andReturn($itemId);
50 $decision1->shouldReceive(
"getPfileId")->andReturn($pfileId);
51 $decision2 = M::mock(ClearingDecision::class);
52 $decision2->shouldReceive(
"getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
53 $decision2->shouldReceive(
"getScope")->atLeast()->once()->withNoArgs()->andReturn(DecisionScopes::ITEM);
54 $decision2->shouldReceive(
"getUploadTreeId")->andReturn($itemId+1);
55 $decision2->shouldReceive(
"getPfileId")->andReturn($pfileId);
56 $decisionIrrel = M::mock(ClearingDecision::class);
57 $decisionIrrel->shouldReceive(
"getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IRRELEVANT);
59 $filteredClearingDecisions = $this->clearingDecisionFilter->filterCurrentClearingDecisions(array($decision1, $decisionIrrel, $decision2));
61 assertThat($this->clearingDecisionFilter->getDecisionOf($filteredClearingDecisions, $itemId, $pfileId), is(sameInstance($decision1)));
62 assertThat($this->clearingDecisionFilter->getDecisionOf($filteredClearingDecisions, $itemId+1, $pfileId), is(sameInstance($decision2)));
63 assertThat($this->clearingDecisionFilter->getDecisionOf($filteredClearingDecisions, $itemId+2, $pfileId), is(sameInstance($decision1)));
75 $decision = M::mock(ClearingDecision::class);
76 $decision->shouldReceive(
"getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
77 $decision->shouldReceive(
"getScope")->atLeast()->once()->withNoArgs()->andReturn(12345);
78 $decision->shouldReceive(
"getUploadTreeId")->andReturn($itemId);
79 $decision->shouldReceive(
"getPfileId")->andReturn($pfileId);
81 $this->clearingDecisionFilter->filterCurrentClearingDecisions(array($decision));
84 public function testFilterCurrentReusableClearingDecisions()
88 $decision1 = M::mock(ClearingDecision::class);
89 $decision1->shouldReceive(
"getUploadTreeId")->andReturn($itemId);
90 $decision2 = M::mock(ClearingDecision::class);
91 $decision2->shouldReceive(
"getUploadTreeId")->andReturn($itemId2);
93 $filteredClearingDecisions = $this->clearingDecisionFilter->filterCurrentReusableClearingDecisions(array($decision1, $decision2));
94 $expecedArray = array($itemId => $decision1, $itemId2 => $decision2 );
96 assertThat($filteredClearingDecisions, containsInAnyOrder($expecedArray));
testCreateClearingResultCreationFailsOfNoEventsWereFound()
Contains business rules for FOSSology.
Various utility functions to filter ClearingDecision.