31 private $clearingEvent;
33 private $agentClearingEvent1;
35 private $agentClearingEvent2;
37 private $licenseDecisionResult;
40 protected function setUp()
42 $this->licenseRef = M::mock(LicenseRef::class);
43 $this->clearingEvent = M::mock(ClearingEvent::class);
45 $this->agentClearingEvent1 = M::mock(AgentClearingEvent::class);
46 $this->agentClearingEvent2 = M::mock(AgentClearingEvent::class);
48 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
51 protected function tearDown()
53 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
56 public function testHasAgentDecisionEventIsTrue()
58 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1, $this->agentClearingEvent2));
59 assertThat($this->licenseDecisionResult->hasAgentDecisionEvent(), is(
true));
62 public function testHasAgentDecisionEventIsFalse()
64 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent);
65 assertThat($this->licenseDecisionResult->hasAgentDecisionEvent(), is(
false));
68 public function testHasDecisionEventIsTrue()
70 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1, $this->agentClearingEvent2));
71 assertThat($this->licenseDecisionResult->hasClearingEvent(), is(
true));
74 public function testHasDecisionEventIsFalse()
76 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1));
77 assertThat($this->licenseDecisionResult->hasClearingEvent(), is(
false));
80 public function testGetLicenseRefFromClearingEvent()
82 $this->clearingEvent->shouldReceive(
"getLicenseRef")->once()->andReturn($this->licenseRef);
83 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
84 assertThat($this->licenseDecisionResult->getLicenseRef(), is($this->licenseRef));
87 public function testGetLicenseRefFromAgentEvents()
89 $this->agentClearingEvent1->shouldReceive(
"getLicenseRef")->once()->andReturn($this->licenseRef);
90 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1, $this->agentClearingEvent2));
91 assertThat($this->licenseDecisionResult->getLicenseRef(), is($this->licenseRef));
94 public function testGetLicenseIdFromClearingEvent()
97 $this->clearingEvent->shouldReceive(
"getLicenseId")->once()->andReturn($licenseId);
98 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
99 assertThat($this->licenseDecisionResult->getLicenseId(), is($licenseId));
103 public function testGetLicenseIdFromAgentEvent()
106 $this->agentClearingEvent1->shouldReceive(
"getLicenseId")->once()->andReturn($licenseId);
107 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1));
108 assertThat($this->licenseDecisionResult->getLicenseId(), is($licenseId));
111 public function testGetLicenseShortName()
113 $licenseShortName =
"<shortName>";
114 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
115 $this->clearingEvent->shouldReceive(
"getLicenseShortName")->once()->andReturn($licenseShortName);
116 assertThat($this->licenseDecisionResult->getLicenseShortName(), is($licenseShortName));
119 public function testGetLicenseFullName()
121 $licenseFullName =
"<fullName>";
122 $this->clearingEvent->shouldReceive(
"getLicenseFullName")->once()->andReturn($licenseFullName);
123 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
124 assertThat($this->licenseDecisionResult->getLicenseFullName(), is($licenseFullName));
127 public function testGetCommentWithClearingEvent()
129 $comment =
"<comment>";
130 $this->clearingEvent->shouldReceive(
"getComment")->once()->andReturn($comment);
131 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
132 assertThat($this->licenseDecisionResult->getComment(), is($comment));
135 public function testGetCommentWithoutClearingEvent()
138 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1));
139 assertThat($this->licenseDecisionResult->getComment(), is($comment));
142 public function testGetReportInfoWithClearingEvent()
144 $reportInfo =
"<reportInfo>";
145 $this->clearingEvent->shouldReceive(
"getReportinfo")->once()->andReturn($reportInfo);
146 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
147 assertThat($this->licenseDecisionResult->getReportinfo(), is($reportInfo));
151 public function testGetAcknowledgementWithClearingEvent()
153 $acknowledgement =
"<acknowledgement>";
154 $this->clearingEvent->shouldReceive(
"getAcknowledgement")->once()->andReturn($acknowledgement);
155 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
156 assertThat($this->licenseDecisionResult->getAcknowledgement(), is($acknowledgement));
159 public function testGetReportInfoWithoutClearingEvent()
162 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1));
163 assertThat($this->licenseDecisionResult->getReportinfo(), is($reportInfo));
166 public function testGetAcknowledgementWithoutClearingEvent()
168 $acknowledgement =
"";
169 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1));
170 assertThat($this->licenseDecisionResult->getAcknowledgement(), is($acknowledgement));
173 public function testIsRemoved()
175 $this->clearingEvent->shouldReceive(
"isRemoved")->once()->andReturn(
true);
176 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
177 assertThat($this->licenseDecisionResult->isRemoved(), is(
true));
180 public function testGetTimeStamp()
183 $this->clearingEvent->shouldReceive(
"getTimeStamp")->once()->andReturn($ts);
184 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
185 assertThat($this->licenseDecisionResult->getTimeStamp(), is($ts));
188 public function testEventTypeWithClearingEvent()
190 $eventType =
"<eventType>";
191 $this->clearingEvent->shouldReceive(
"getEventType")->once()->andReturn($eventType);
192 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
193 assertThat($this->licenseDecisionResult->getEventType(), is($eventType));
196 public function testEventTypeWithoutClearingEvent()
198 $eventType =
"<eventType>";
199 $this->agentClearingEvent1->shouldReceive(
"getEventType")->once()->andReturn($eventType);
200 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1));
201 assertThat($this->licenseDecisionResult->getEventType(), is($eventType));
204 public function testGetLicenseIdWithClearingEvent()
207 $this->clearingEvent->shouldReceive(
"getLicenseId")->once()->andReturn($licenseId);
208 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
209 assertThat($this->licenseDecisionResult->getLicenseId(), is($licenseId));
212 public function testGetLicenseIdWithoutClearingEvent()
215 $this->agentClearingEvent1->shouldReceive(
"getLicenseId")->once()->andReturn($licenseId);
216 $this->licenseDecisionResult =
new ClearingResult(null, array($this->agentClearingEvent1));
217 assertThat($this->licenseDecisionResult->getLicenseId(), is($licenseId));
220 public function testGetClearingEvent()
222 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1));
223 assertThat($this->licenseDecisionResult->getClearingEvent(), is($this->clearingEvent));
226 public function testGetAgentClearingEvents()
228 $this->licenseDecisionResult =
new ClearingResult($this->clearingEvent, array($this->agentClearingEvent1, $this->agentClearingEvent2));
229 assertThat($this->licenseDecisionResult->getAgentDecisionEvents(), is(array(
230 $this->agentClearingEvent1, $this->agentClearingEvent2)));
testCreateClearingResultCreationFailsOfNoEventsWereFound()