protected function setUp()
 {
     $this->timestamp = time();
     $this->clearingLicense = M::mock(ClearingLicense::classname());
     $this->licenseDecisionEvent = new ClearingEvent($this->eventId, $this->uploadTreeId, $this->timestamp, $this->userId, $this->groupId, $this->eventType, $this->clearingLicense);
     $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
 }
 public function testFilterEffectiveEventsOppositeIdenticalEventsOverwriteInOtherOrder()
 {
     $events = array();
     $licenseRef1 = M::mock(ClearingLicense::classname());
     $licenseRef1->shouldReceive("getLicenseId")->withNoArgs()->andReturn("fortyTwo");
     $events[] = $this->createEvent($this->timestamp, $licenseRef1);
     $licenseRef2 = M::mock(ClearingLicense::classname());
     $licenseRef2->shouldReceive("getLicenseId")->withNoArgs()->andReturn("fortyTwo");
     $events[] = $this->createEvent($this->timestamp + 60, $licenseRef2);
     $filteredEvents = $this->clearingEventProcessor->filterEffectiveEvents($events);
     assertThat($filteredEvents, is(arrayWithSize(1)));
     assertThat($filteredEvents, hasKeyValuePair('fortyTwo', $events[1]));
 }
 public function testPositiveLicenses()
 {
     $addedLic = M::mock(LicenseRef::classname());
     $addedClearingLic = M::mock(ClearingLicense::classname());
     $addedClearingLic->shouldReceive('isRemoved')->withNoArgs()->andReturn(false);
     $addedClearingLic->shouldReceive('getLicenseRef')->withNoArgs()->andReturn($addedLic);
     $removedClearingLic = M::mock(ClearingLicense::classname());
     $removedClearingLic->shouldReceive('isRemoved')->andReturn(true);
     $removedClearingEvent = M::mock(ClearingEvent::classname());
     $this->clearingEvent->shouldReceive('getClearingLicense')->andReturn($addedClearingLic);
     $removedClearingEvent->shouldReceive('getClearingLicense')->andReturn($removedClearingLic);
     $clearingDec = $this->clearingDecisionBuilder->setClearingEvents(array($this->clearingEvent, $removedClearingEvent))->build();
     assertThat($clearingDec->getPositiveLicenses(), is(arrayContaining($addedLic)));
 }