protected function setUp() { $this->licenseRef = M::mock(LicenseRef::classname()); $this->clearingEvent = M::mock(ClearingEvent::classname()); $this->agentClearingEvent1 = M::mock(AgentClearingEvent::classname()); $this->agentClearingEvent2 = M::mock(AgentClearingEvent::classname()); $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount(); }
protected function setUp() { $this->timestamp = time(); $this->clearingEventProcessor = new ClearingEventProcessor(); $this->addedLicense = M::mock(ClearingLicense::classname()); $this->addedLicense->shouldReceive("getShortName")->withNoArgs()->andReturn($this->addedName); $this->addedLicense->shouldReceive("getId")->withNoArgs()->andReturn($this->addedId); $this->addedEvent = M::mock(ClearingEvent::classname()); $this->addedEvent->shouldReceive("getLicenseShortName")->withNoArgs()->andReturn($this->addedName); $this->addedEvent->shouldReceive("getLicenseId")->withNoArgs()->andReturn($this->addedId); $this->addedEvent->shouldReceive("getClearingLicense")->withNoArgs()->andReturn($this->addedLicense); $this->addedEvent->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp); $this->addedEvent->shouldReceive("isRemoved")->withNoArgs()->andReturn(false); $this->removedLicense = M::mock(ClearingLicense::classname()); $this->removedLicense->shouldReceive("getShortName")->withNoArgs()->andReturn($this->removedName); $this->removedLicense->shouldReceive("getId")->withNoArgs()->andReturn($this->removedId); $this->removedEvent = M::mock(ClearingEvent::classname()); $this->removedEvent->shouldReceive("getLicenseShortName")->withNoArgs()->andReturn($this->removedName); $this->removedEvent->shouldReceive("getLicenseId")->withNoArgs()->andReturn($this->removedId); $this->removedEvent->shouldReceive("getClearingLicense")->withNoArgs()->andReturn($this->removedLicense); $this->removedEvent->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp); $this->removedEvent->shouldReceive("isRemoved")->withNoArgs()->andReturn(true); }
public function testRelevantClearingEvents() { $groupId = 701; $this->buildProposals(array(array(301, 1, $groupId, 401, false, -99), array(301, 2, $groupId, 402, true, -98), array(301, 2, $groupId, 401, true, -97)), $firstEventId = 0); $this->buildDecisions(array(array(301, 1, $groupId, DecisionTypes::IDENTIFIED, -90, DecisionScopes::REPO, array($firstEventId, $firstEventId + 1, $firstEventId + 2)))); $itemTreeBounds = M::mock(ItemTreeBounds::classname()); $itemTreeBounds->shouldReceive('getItemId')->andReturn(301); $itemTreeBounds->shouldReceive('getUploadTreeTableName')->andReturn('uploadtree'); $itemTreeBounds->shouldReceive('containsFiles')->andReturn(false); $itemTreeBounds->shouldReceive('getUploadId')->andReturn($this->items[301][0]); $itemTreeBounds->shouldReceive('getLeft')->andReturn($this->items[301][4]); $itemTreeBounds->shouldReceive('getRight')->andReturn($this->items[301][5]); $events1 = $this->clearingDao->getRelevantClearingEvents($itemTreeBounds, $groupId); assertThat($events1, arrayWithSize(2)); assertThat($events1, hasKeyInArray(401)); assertThat($events1, hasKeyInArray(402)); assertThat($events1[401], is(anInstanceOf(ClearingEvent::classname()))); assertThat($events1[402]->getEventId(), is($firstEventId + 1)); assertThat($events1[401]->getEventId(), is($firstEventId + 2)); }
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))); }