/** * @param LicenseRef $licenseRef * @return string */ public function getLicenseTextUrl(LicenseRef $licenseRef) { $uri = Traceback_uri() . '?mod=popup-license&rf=' . $licenseRef->getId(); $title = _('License text'); $licenseShortNameWithLink = '<a title="' . $licenseRef->getFullName() . '" href="javascript:;" onclick="javascript:window.open(\'' . $uri . '\',\'' . $title . '\',\'width=600,height=400,toolbar=no,scrollbars=yes,resizable=yes\');">' . $licenseRef->getShortName() . '</a>'; return $licenseShortNameWithLink; }
public function run($uploadId, $userId = 2, $groupId = 2, $jobId = 1, $args = "") { $GLOBALS['userId'] = $userId; $GLOBALS['jobId'] = $jobId; $GLOBALS['groupId'] = $groupId; /* these appear not to be used by the reuser: mock them to something wrong */ $this->clearingEventProcessor = M::mock(LicenseRef::classname()); $this->decisionTypes = M::mock(LicenseRef::classname()); $this->agentLicenseEventProcessor = M::mock(LicenseRef::classname()); $container = M::mock('Container'); $container->shouldReceive('get')->with('db.manager')->andReturn($this->dbManager); $container->shouldReceive('get')->with('dao.agent')->andReturn($this->agentDao); $container->shouldReceive('get')->with('dao.clearing')->andReturn($this->clearingDao); $container->shouldReceive('get')->with('dao.upload')->andReturn($this->uploadDao); $container->shouldReceive('get')->with('decision.types')->andReturn($this->decisionTypes); $container->shouldReceive('get')->with('businessrules.clearing_event_processor')->andReturn($this->clearingEventProcessor); $container->shouldReceive('get')->with('businessrules.clearing_decision_filter')->andReturn($this->clearingDecisionFilter); $container->shouldReceive('get')->with('businessrules.clearing_decision_processor')->andReturn($this->clearingDecisionProcessor); $container->shouldReceive('get')->with('businessrules.agent_license_event_processor')->andReturn($this->agentLicenseEventProcessor); $container->shouldReceive('get')->with('dao.tree')->andReturn($this->treeDao); $GLOBALS['container'] = $container; $fgetsMock = M::mock(\Fossology\Lib\Agent\FgetsMock::classname()); $fgetsMock->shouldReceive("fgets")->with(STDIN)->andReturn($uploadId, false); $GLOBALS['fgetsMock'] = $fgetsMock; $exitval = 0; ob_start(); include dirname(dirname(__DIR__)) . '/agent/reuser.php'; $output = ob_get_clean(); return array(true, $output, $exitval); }
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(); }
public function testGetLicenseTextLink() { $id = 432; $shortName = "<shortName>"; $fullName = "<fullName>"; $licenseRef = M::mock(LicenseRef::classname()); $licenseRef->shouldReceive("getId")->once()->withNoArgs()->andReturn($id); $licenseRef->shouldReceive("getShortName")->once()->withNoArgs()->andReturn($shortName); $licenseRef->shouldReceive("getFullName")->once()->withNoArgs()->andReturn($fullName); $linkUrl = $this->urlBuilder->getLicenseTextUrl($licenseRef); assertThat($linkUrl, is("<a title=\"{$fullName}\" href=\"javascript:;\" " . "onclick=\"javascript:window.open('http://localhost/repo?mod=popup-license&rf={$id}'," . "'License text','width=600,height=400,toolbar=no,scrollbars=yes,resizable=yes');\">{$shortName}</a>")); }
public function testGetLicenseFullName() { $licenseFullName = "<licenseFullName>"; $this->licenseRef->shouldReceive('getFullName')->once()->withNoArgs()->andReturn($licenseFullName); assertThat($this->agentClearingEvent->getLicenseFullName(), is($licenseFullName)); }
/** * @return M\MockInterface */ protected function createLicenseMatch($licenseId, $licenseShortName, $agentId, $agentName, $matchId, $percentage) { $licenseRef = M::mock(LicenseRef::classname()); $licenseRef->shouldReceive("getId")->withNoArgs()->andReturn($licenseId); $licenseRef->shouldReceive("getShortName")->withNoArgs()->andReturn($licenseShortName); $agentRef = M::mock(LicenseRef::classname()); $agentRef->shouldReceive("getAgentId")->withNoArgs()->andReturn($agentId); $agentRef->shouldReceive("getAgentName")->withNoArgs()->andReturn($agentName); $agentRef->shouldReceive("getAgentName")->withNoArgs()->andReturn($agentName); $licenseMatch = M::mock(LicenseMatch::classname()); $licenseMatch->shouldReceive("getLicenseRef")->withNoArgs()->andReturn($licenseRef); $licenseMatch->shouldReceive("getAgentRef")->withNoArgs()->andReturn($agentRef); $licenseMatch->shouldReceive("getLicenseFileId")->withNoArgs()->andReturn($matchId); $licenseMatch->shouldReceive("getPercentage")->withNoArgs()->andReturn($percentage); return array($licenseMatch, $licenseRef, $agentRef); }
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))); }
/** * @return int */ public function getLicenseId() { return $this->licenseRef->getId(); }
/** * @return string */ public function getLicenseFullName() { return $this->licenseRef->getFullName(); }