Unverified Commit 5aa9a204 authored by Maximilian Huber's avatar Maximilian Huber Committed by GitHub

Merge pull request #1180 from robertvolkmann/feat/remove-object-class

feat(php): Replaced the class Object by builtin features.

review-by: @GMishx 
review-by: maximilian.huber@tngtech.com
tested-by: @GMishx 
tested-by: travis
parents 3ceca0cc 49ffd739
......@@ -54,7 +54,7 @@ class CopyrightScheduledTest extends \PHPUnit\Framework\TestCase
$logger = new Logger("CopyrightSchedulerTest");
$this->licenseDao = new LicenseDao($this->dbManager);
$this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
$this->uploadPermDao = \Mockery::mock(UploadPermissionDao::class);
$this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
$this->copyrightDao = new CopyrightDao($this->dbManager, $this->uploadDao);
}
......
......@@ -22,12 +22,11 @@ use Fossology\DeciderJob\UI\DeciderJobAgentPlugin;
use Fossology\Lib\Dao\UploadDao;
use Fossology\Lib\Db\DbManager;
use Fossology\Lib\Plugin\AgentPlugin;
use Fossology\Lib\Util\Object;
use Symfony\Component\Config\Definition\Exception\Exception;
include_once(__DIR__ . "/../../lib/php/common-job.php");
class BulkReuser extends Object
class BulkReuser
{
/** @var DbManager */
private $dbManager;
......
......@@ -98,7 +98,7 @@ class SchedulerTestRunnerMock implements SchedulerTestRunner
$container->shouldReceive('get')->with('businessrules.agent_license_event_processor')->andReturn($this->agentLicenseEventProcessor);
$GLOBALS['container'] = $container;
$fgetsMock = M::mock(\Fossology\Lib\Agent\FgetsMock::classname());
$fgetsMock = M::mock(\Fossology\Lib\Agent\FgetsMock::class);
$fgetsMock->shouldReceive("fgets")->with(STDIN)->andReturn($uploadId, false);
$GLOBALS['fgetsMock'] = $fgetsMock;
......
......@@ -78,7 +78,7 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
$this->licenseDao = new LicenseDao($this->dbManager);
$logger = M::mock('Monolog\Logger');
$this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
$this->uploadPermDao = \Mockery::mock(UploadPermissionDao::class);
$this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
$this->highlightDao = new HighlightDao($this->dbManager);
$agentDao = new AgentDao($this->dbManager, $logger);
......
......@@ -58,15 +58,15 @@ class DeciderAgentTest extends \PHPUnit\Framework\TestCase
{
global $container;
$container = M::mock('ContainerBuilder');
$this->dbManager = M::mock(DbManager::classname());
$this->agentDao = M::mock(AgentDao::classname());
$this->dbManager = M::mock(DbManager::class);
$this->agentDao = M::mock(AgentDao::class);
$this->agentDao->shouldReceive('getCurrentAgentId')->andReturn(1234);
$this->highlightDao = M::mock(HighlightDao::classname());
$this->uploadDao = M::mock(UploadDao::classname());
$this->highlightDao = M::mock(HighlightDao::class);
$this->uploadDao = M::mock(UploadDao::class);
$this->showJobsDao = new ShowJobsDao($this->dbManager, $this->uploadDao);
$this->clearingDao = M::mock(ClearingDao::classname());
$this->clearingDecisionProcessor = M::mock(ClearingDecisionProcessor::classname());
$this->agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::classname());
$this->clearingDao = M::mock(ClearingDao::class);
$this->clearingDecisionProcessor = M::mock(ClearingDecisionProcessor::class);
$this->agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::class);
$container->shouldReceive('get')->withArgs(array('db.manager'))->andReturn($this->dbManager);
$container->shouldReceive('get')->withArgs(array('dao.agent'))->andReturn($this->agentDao);
......@@ -74,7 +74,7 @@ class DeciderAgentTest extends \PHPUnit\Framework\TestCase
$container->shouldReceive('get')->with('dao.show_jobs')->andReturn($this->showJobsDao);
$container->shouldReceive('get')->withArgs(array('dao.upload'))->andReturn($this->uploadDao);
$container->shouldReceive('get')->withArgs(array('dao.clearing'))->andReturn($this->clearingDao);
$container->shouldReceive('get')->withArgs(array('decision.types'))->andReturn(M::mock(DecisionTypes::classname()));
$container->shouldReceive('get')->withArgs(array('decision.types'))->andReturn(M::mock(DecisionTypes::class));
$container->shouldReceive('get')->withArgs(array('businessrules.clearing_decision_processor'))->andReturn($this->clearingDecisionProcessor);
$container->shouldReceive('get')->withArgs(array('businessrules.agent_license_event_processor'))->andReturn($this->agentLicenseEventProcessor);
$this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
......@@ -166,7 +166,7 @@ class DeciderAgentTest extends \PHPUnit\Framework\TestCase
*/
protected function createLicenseMatch($agentName, $matchId)
{
$licenseMatch = M::mock(LicenseMatch::classname());
$licenseMatch = M::mock(LicenseMatch::class);
$licenseMatch->shouldReceive("getLicenseFileId")->withNoArgs()->andReturn($matchId);
return $licenseMatch;
}
......@@ -210,7 +210,7 @@ class DeciderAgentTest extends \PHPUnit\Framework\TestCase
*/
protected function createLicenseMatchWithLicId($licId)
{
$licenseMatch = M::mock(LicenseMatch::classname());
$licenseMatch = M::mock(LicenseMatch::class);
$licenseMatch->shouldReceive("getLicenseId")->withNoArgs()->andReturn($licId);
return $licenseMatch;
}
......
......@@ -92,7 +92,7 @@ class SchedulerTestRunnerMock implements SchedulerTestRunner
$container->shouldReceive('get')->with('businessrules.agent_license_event_processor')->andReturn($this->agentLicenseEventProcessor);
$GLOBALS['container'] = $container;
$fgetsMock = M::mock(\Fossology\Lib\Agent\FgetsMock::classname());
$fgetsMock = M::mock(\Fossology\Lib\Agent\FgetsMock::class);
$fgetsMock->shouldReceive("fgets")->with(STDIN)->andReturn($uploadId, false);
$GLOBALS['fgetsMock'] = $fgetsMock;
......
......@@ -76,7 +76,7 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
$logger = M::mock('Monolog\Logger');
$this->licenseDao = new LicenseDao($this->dbManager);
$this->uploadPermDao = \Mockery::mock(UploadPermissionDao::classname());
$this->uploadPermDao = \Mockery::mock(UploadPermissionDao::class);
$this->uploadDao = new UploadDao($this->dbManager, $logger, $this->uploadPermDao);
$this->highlightDao = new HighlightDao($this->dbManager);
$agentDao = new AgentDao($this->dbManager, $logger);
......@@ -244,13 +244,13 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
$this->setUpTables();
$this->setUpRepo();
$dbManager = M::mock(DbManager::classname());
$agentDao = M::mock(AgentDao::classname());
$clearingDao = M::mock(ClearingDao::classname());
$uploadDao = M::mock(UploadDao::classname());
$highlightDao = M::mock(HighlightDao::classname());
$decisionProcessor = M::mock(ClearingDecisionProcessor::classname());
$agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::classname());
$dbManager = M::mock(DbManager::class);
$agentDao = M::mock(AgentDao::class);
$clearingDao = M::mock(ClearingDao::class);
$uploadDao = M::mock(UploadDao::class);
$highlightDao = M::mock(HighlightDao::class);
$decisionProcessor = M::mock(ClearingDecisionProcessor::class);
$agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::class);
$uploadId = 13243;
......@@ -266,10 +266,10 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
$itemIds = array(4343, 43);
$bounds0 = M::mock(ItemTreeBounds::classname());
$bounds0 = M::mock(ItemTreeBounds::class);
$bounds0->shouldReceive('getItemId')->andReturn($itemIds[0]);
$bounds0->shouldReceive('containsFiles')->andReturn(false);
$bounds1 = M::mock(ItemTreeBounds::classname());
$bounds1 = M::mock(ItemTreeBounds::class);
$bounds1->shouldReceive('getItemId')->andReturn($itemIds[1]);
$bounds1->shouldReceive('containsFiles')->andReturn(false);
$bounds = array($bounds0, $bounds1);
......@@ -285,7 +285,7 @@ class SchedulerTest extends \PHPUnit\Framework\TestCase
/* dummy expectations needed for unmockable LicenseMap constructor */
$dbManager->shouldReceive('prepare');
$res = M::Mock(DbManager::classname());
$res = M::Mock(DbManager::class);
$dbManager->shouldReceive('execute')->andReturn($res);
$row1 = array('rf_fk' => 2334, 'parent_fk' => 1);
$row2 = array('rf_fk' => 2333, 'parent_fk' => 1);
......
......@@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
namespace Fossology\Lib\Agent;
use Fossology\Lib\Util\Object;
use Fossology\Lib\Db\DbManager;
use Fossology\Lib\Dao\AgentDao;
use Symfony\Component\DependencyInjection\ContainerBuilder;
......@@ -28,7 +27,7 @@ require_once(dirname(dirname(__FILE__))."/common-cli.php");
define("ALARM_SECS", 30);
abstract class Agent extends Object
abstract class Agent
{
private $agentName;
private $agentVersion;
......
......@@ -116,7 +116,7 @@ class LicenseCsvExportTest extends \PHPUnit\Framework\TestCase
public function testSetDelimiter()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvExport = new LicenseCsvExport($dbManager);
$reflection = new \ReflectionClass($licenseCsvExport);
$delimiter = $reflection->getProperty('delimiter');
......@@ -131,7 +131,7 @@ class LicenseCsvExportTest extends \PHPUnit\Framework\TestCase
public function testSetEnclosure()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvExport = new LicenseCsvExport($dbManager);
$reflection = new \ReflectionClass($licenseCsvExport);
$enclosure = $reflection->getProperty('enclosure');
......
......@@ -54,7 +54,7 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
public function testHandleCsvLicense()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
$nkMap = array('licA'=>101,'licB'=>false,'licC'=>false,'licE'=>false,'licF'=>false,'licG'=>false,'licH'=>false,'licZ'=>100);
Reflectory::setObjectsProperty($licenseCsvImport, 'nkMap', $nkMap);
......@@ -111,7 +111,7 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
public function testHandleHeadCsv()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
assertThat(Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleHeadCsv',array(array('shortname','foo','text','fullname','notes','bar'))),
......@@ -126,14 +126,14 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
*/
public function testHandleHeadCsv_missingMandidatoryKey()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
Reflectory::invokeObjectsMethodnameWith($licenseCsvImport,'handleHeadCsv',array(array('shortname','foo','text')));
}
public function testSetDelimiter()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
$licenseCsvImport->setDelimiter('|');
......@@ -145,7 +145,7 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
public function testSetEnclosure()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
$licenseCsvImport->setEnclosure('|');
......@@ -157,7 +157,7 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
public function testHandleCsv()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
Reflectory::invokeObjectsMethodnameWith($licenseCsvImport, 'handleCsv', array(array('shortname','foo','text','fullname','notes')));
......@@ -176,7 +176,7 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
public function testHandleFileIfFileNotExists()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
$msg = $licenseCsvImport->handleFile('/tmp/thisFileNameShouldNotExists');
assertThat($msg, is(equalTo(_('Internal error'))));
......@@ -184,7 +184,7 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
public function testHandleFileIfFileIsNotParsable()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
$msg = $licenseCsvImport->handleFile(__FILE__);
assertThat($msg, startsWith( _('Error while parsing file')));
......@@ -192,7 +192,7 @@ class LicenseCsvImportTest extends \PHPUnit\Framework\TestCase
public function testHandleFile()
{
$dbManager = M::mock(DbManager::classname());
$dbManager = M::mock(DbManager::class);
$licenseCsvImport = new LicenseCsvImport($dbManager);
$filename = tempnam("/tmp", "FOO");
$handle = fopen($filename, 'w');
......
......@@ -25,9 +25,8 @@ use Fossology\Lib\Data\LicenseMatch;
use Fossology\Lib\Data\LicenseRef;
use Fossology\Lib\Data\Tree\ItemTreeBounds;
use Fossology\Lib\Proxy\LatestScannerProxy;
use Fossology\Lib\Util\Object;
class AgentLicenseEventProcessor extends Object
class AgentLicenseEventProcessor
{
private $latestAgentMapCache = array();
/** @var LicenseDao */
......
......@@ -27,9 +27,8 @@ use Fossology\Lib\Data\DecisionTypes;
use Fossology\Lib\Data\Tree\ItemTreeBounds;
use Fossology\Lib\Db\DbManager;
use Fossology\Lib\Exception;
use Fossology\Lib\Util\Object;
class ClearingDecisionProcessor extends Object
class ClearingDecisionProcessor
{
const NO_LICENSE_KNOWN_DECISION_TYPE = 2;
......
......@@ -20,9 +20,8 @@ namespace Fossology\Lib\BusinessRules;
use Fossology\Lib\Data\Clearing\ClearingEvent;
use Fossology\Lib\Data\LicenseRef;
use Fossology\Lib\Util\Object;
class ClearingEventProcessor extends Object
class ClearingEventProcessor
{
/**
......@@ -59,4 +58,4 @@ class ClearingEventProcessor extends Object
return $reducedEvents;
}
}
\ No newline at end of file
}
......@@ -21,9 +21,8 @@ namespace Fossology\Lib\BusinessRules;
use Fossology\Lib\Data\LicenseRef;
use Fossology\Lib\Db\DbManager;
use Fossology\Lib\Proxy\LicenseViewProxy;
use Fossology\Lib\Util\Object;
class LicenseMap extends Object
class LicenseMap
{
const CONCLUSION = 1;
const TRIVIAL = 2;
......@@ -141,4 +140,4 @@ class LicenseMap extends Object
return $sql;
}
}
\ No newline at end of file
}
......@@ -19,9 +19,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
namespace Fossology\Lib\BusinessRules;
use Fossology\Lib\Db\DbManager;
use Fossology\Lib\Util\Object;
class ObligationMap extends Object
class ObligationMap
{
/** @var DbManager */
......
......@@ -42,15 +42,15 @@ class AgentLicenseEventProcessorTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->licenseDao = M::mock(LicenseDao::classname());
$this->agentsDao = M::mock(AgentDao::classname());
$this->licenseDao = M::mock(LicenseDao::class);
$this->agentsDao = M::mock(AgentDao::class);
$this->itemTreeBounds = M::mock(ItemTreeBounds::classname());
$this->itemTreeBounds = M::mock(ItemTreeBounds::class);
$this->agentLicenseEventProcessor = new AgentLicenseEventProcessor($this->licenseDao, $this->agentsDao);
global $container;
$this->dbManagerMock = M::mock(DbManager::classname());
$this->dbManagerMock = M::mock(DbManager::class);
$this->dbManagerMock->shouldReceive('prepare');
$this->dbManagerMock->shouldReceive('execute');
$this->dbManagerMock->shouldReceive('fetchArray')
......@@ -199,16 +199,16 @@ class AgentLicenseEventProcessorTest extends \PHPUnit\Framework\TestCase
*/
protected function createLicenseMatch($licenseId, $licenseShortName, $agentId, $agentName, $matchId, $percentage)
{
$licenseRef = M::mock(LicenseRef::classname());
$licenseRef = M::mock(LicenseRef::class);
$licenseRef->shouldReceive("getId")->withNoArgs()->andReturn($licenseId);
$licenseRef->shouldReceive("getShortName")->withNoArgs()->andReturn($licenseShortName);
$agentRef = M::mock(LicenseRef::classname());
$agentRef = M::mock(LicenseRef::class);
$agentRef->shouldReceive("getAgentId")->withNoArgs()->andReturn($agentId);
$agentRef->shouldReceive("getAgentName")->withNoArgs()->andReturn($agentName);
$agentRef->shouldReceive("getAgentName")->withNoArgs()->andReturn($agentName);
$licenseMatch = M::mock(LicenseMatch::classname());
$licenseMatch = M::mock(LicenseMatch::class);
$licenseMatch->shouldReceive("getLicenseRef")->withNoArgs()->andReturn($licenseRef);
$licenseMatch->shouldReceive("getAgentRef")->withNoArgs()->andReturn($agentRef);
$licenseMatch->shouldReceive("getLicenseFileId")->withNoArgs()->andReturn($matchId);
......
......@@ -39,17 +39,17 @@ class ClearingDecisionFilterTest extends \PHPUnit\Framework\TestCase {
public function testFilterCurrentClearingDecisions() {
$itemId = 543;
$pfileId = 432;
$decision1 = M::mock(ClearingDecision::classname());
$decision1 = M::mock(ClearingDecision::class);
$decision1->shouldReceive("getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
$decision1->shouldReceive("getScope")->atLeast()->once()->withNoArgs()->andReturn(DecisionScopes::REPO);
$decision1->shouldReceive("getUploadTreeId")->andReturn($itemId);
$decision1->shouldReceive("getPfileId")->andReturn($pfileId);
$decision2 = M::mock(ClearingDecision::classname());
$decision2 = M::mock(ClearingDecision::class);
$decision2->shouldReceive("getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
$decision2->shouldReceive("getScope")->atLeast()->once()->withNoArgs()->andReturn(DecisionScopes::ITEM);
$decision2->shouldReceive("getUploadTreeId")->andReturn($itemId+1);
$decision2->shouldReceive("getPfileId")->andReturn($pfileId);
$decisionIrrel = M::mock(ClearingDecision::classname());
$decisionIrrel = M::mock(ClearingDecision::class);
$decisionIrrel->shouldReceive("getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IRRELEVANT);
$filteredClearingDecisions = $this->clearingDecisionFilter->filterCurrentClearingDecisions(array($decision1, $decisionIrrel, $decision2));
......@@ -68,7 +68,7 @@ class ClearingDecisionFilterTest extends \PHPUnit\Framework\TestCase {
{
$itemId = 543;
$pfileId = 432;
$decision = M::mock(ClearingDecision::classname());
$decision = M::mock(ClearingDecision::class);
$decision->shouldReceive("getType")->atLeast()->once()->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
$decision->shouldReceive("getScope")->atLeast()->once()->withNoArgs()->andReturn(12345);
$decision->shouldReceive("getUploadTreeId")->andReturn($itemId);
......@@ -80,9 +80,9 @@ class ClearingDecisionFilterTest extends \PHPUnit\Framework\TestCase {
public function testFilterCurrentReusableClearingDecisions() {
$itemId = 543;
$itemId2 = 432;
$decision1 = M::mock(ClearingDecision::classname());
$decision1 = M::mock(ClearingDecision::class);
$decision1->shouldReceive("getUploadTreeId")->andReturn($itemId);
$decision2 = M::mock(ClearingDecision::classname());
$decision2 = M::mock(ClearingDecision::class);
$decision2->shouldReceive("getUploadTreeId")->andReturn($itemId2);
$filteredClearingDecisions = $this->clearingDecisionFilter->filterCurrentReusableClearingDecisions(array($decision1, $decision2));
......
......@@ -74,15 +74,15 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
$this->timestamp = time();
$this->includeSubFolders = false;
$this->clearingDao = M::mock(ClearingDao::classname());
$this->agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::classname());
$this->clearingDao = M::mock(ClearingDao::class);
$this->agentLicenseEventProcessor = M::mock(AgentLicenseEventProcessor::class);
$this->clearingEventProcessor = new ClearingEventProcessor();
$this->itemTreeBounds = M::mock(ItemTreeBounds::classname());
$this->itemTreeBounds = M::mock(ItemTreeBounds::class);
$this->itemTreeBounds->shouldReceive("getItemId")->withNoArgs()->andReturn($this->uploadTreeId);
$this->itemTreeBounds->shouldReceive("getPfileId")->withNoArgs()->andReturn($this->pfileId);
$this->dbManager = M::mock(DbManager::classname());
$this->dbManager = M::mock(DbManager::class);
$this->dbManager->shouldReceive('begin')->withNoArgs();
$this->dbManager->shouldReceive('commit')->withNoArgs();
......@@ -110,7 +110,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
->with($this->itemTreeBounds)
->andReturn(array());
$clearingDecision = M::mock(ClearingDecision::classname());
$clearingDecision = M::mock(ClearingDecision::class);
$clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp-3600);
$clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
$clearingDecision->shouldReceive("getClearingEvents")->withNoArgs()->andReturn(array());
......@@ -136,7 +136,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
$this->agentLicenseEventProcessor->shouldReceive("getScannerEvents")
->with($this->itemTreeBounds)->andReturn(array());
$clearingDecision = M::mock(ClearingDecision::classname());
$clearingDecision = M::mock(ClearingDecision::class);
$clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp-3600);
$clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
$clearingDecision->shouldReceive("getScope")->withNoArgs()->andReturn(DecisionScopes::ITEM);
......@@ -165,7 +165,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
$this->agentLicenseEventProcessor->shouldReceive("getScannerEvents")
->with($this->itemTreeBounds)->andReturn(array());
$clearingDecision = M::mock(ClearingDecision::classname());
$clearingDecision = M::mock(ClearingDecision::class);
$clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp-3600);
$clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
$clearingDecision->shouldReceive("getScope")->withNoArgs()->andReturn($isGlobal);
......@@ -194,7 +194,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
->with($this->itemTreeBounds, $this->groupId, $this->includeSubFolders)
->andReturn(array());
$clearingDecision = M::mock(ClearingDecision::classname());
$clearingDecision = M::mock(ClearingDecision::class);
$clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp-3600);
$clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IRRELEVANT);
$clearingDecision->shouldReceive("getClearingEvents")->withNoArgs()->andReturn(array());
......@@ -224,7 +224,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
->with($this->itemTreeBounds, $this->groupId, $this->includeSubFolders)
->andReturn(array($licenseRef->getId() => $addedEvent));
$clearingDecision = M::mock(ClearingDecision::classname());
$clearingDecision = M::mock(ClearingDecision::class);
$clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp-3600);
$clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IRRELEVANT);
$clearingDecision->shouldReceive("getClearingEvents")->withNoArgs()->andReturn(array());
......@@ -256,7 +256,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
->with($this->itemTreeBounds, $this->groupId, $this->includeSubFolders)
->andReturn(array($licenseRef->getId() => $removedEvent));
$clearingDecision = M::mock(ClearingDecision::classname());
$clearingDecision = M::mock(ClearingDecision::class);
$clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp-3600);
$clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IRRELEVANT);
$clearingDecision->shouldReceive("getClearingEvents")->withNoArgs()->andReturn(array());
......@@ -288,7 +288,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
$this->agentLicenseEventProcessor->shouldReceive("getScannerEvents")
->with($this->itemTreeBounds)->andReturn($scannerResults);
$clearingDecision = M::mock(ClearingDecision::classname());
$clearingDecision = M::mock(ClearingDecision::class);
$clearingDecision->shouldReceive("getTimeStamp")->withNoArgs()->andReturn($this->timestamp-3600);
$clearingDecision->shouldReceive("getType")->withNoArgs()->andReturn(DecisionTypes::IDENTIFIED);
$clearingDecision->shouldReceive("getClearingEvents")->withNoArgs()->andReturn(array());
......@@ -505,7 +505,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
$this->agentLicenseEventProcessor->shouldReceive("getScannerEvents")
->with($this->itemTreeBounds,LicenseMap::CONCLUSION)->andReturn($scannerResults);
$licenseMap = M::mock(LicenseMap::classname());
$licenseMap = M::mock(LicenseMap::class);
$licenseMap->shouldReceive('getProjectedId')->andReturnUsing(function($id) {return $id;});
$licenseMap->shouldReceive('getUsage')->andReturn(LicenseMap::CONCLUSION);
......@@ -540,7 +540,7 @@ class ClearingDecisionProcessorTest extends \PHPUnit\Framework\TestCase
{
$licenseRef = new LicenseRef($licenseId, $licenseShortname, $licenseFullName);
$agentRef = M::mock(AgentRef::classname());
$agentRef = M::mock(AgentRef::class);
$scannerEvents = array(
$licenseId => array(new AgentClearingEvent($licenseRef, $agentRef, self::MATCH_ID, self::PERCENTAGE))
......
......@@ -49,21 +49,21 @@ class ClearingEventProcessorTest extends \PHPUnit\Framework\TestCase
$this->timestamp = time();
$this->clearingEventProcessor = new ClearingEventProcessor();
$this->addedLicense = M::mock(ClearingLicense::classname());
$this->addedLicense = M::mock(ClearingLicense::class);
$this->addedLicense->shouldReceive("getShortName")->withNoArgs()->andReturn($this->addedName);
$this->addedLicense->shouldReceive("getId")->withNoArgs()->andReturn($this->addedId);
$this->addedEvent = M::mock(ClearingEvent::classname());
$this->addedEvent = M::mock(ClearingEvent::class);
$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 = M::mock(ClearingLicense::class);
$this->removedLicense->shouldReceive("getShortName")->withNoArgs()->andReturn($this->removedName);
$this->removedLicense->shouldReceive("getId")->withNoArgs()->andReturn($this->removedId);
$this->removedEvent = M::mock(ClearingEvent::classname());
$this->removedEvent = M::mock(ClearingEvent::class);
$this->removedEvent->shouldReceive("getLicenseShortName")->withNoArgs()->andReturn($this->removedName);
$this->removedEvent->shouldReceive("getLicenseId")->withNoArgs()->andReturn($this->removedId);
$this->removedEvent->shouldReceive("getClearingLicense")->withNoArgs()->andReturn($this->removedLicense);
......@@ -81,7 +81,7 @@ class ClearingEventProcessorTest extends \PHPUnit\Framework\TestCase
*/
protected function createEvents()
{
$license = M::mock(ClearingLicense::classname());
$license = M::mock(ClearingLicense::class);
$events = array();
$events[] = $this->createEvent($this->timestamp, $license);
......@@ -108,11 +108,11 @@ class ClearingEventProcessorTest extends \PHPUnit\Framework\TestCase
$licAId = 42;
$licBId = 23;
$license1 = M::mock(ClearingLicense::classname());
$license1 = M::mock(ClearingLicense::class);
$license1->shouldReceive("getLicenseId")->withNoArgs()->andReturn($licAId);
$events[] = $this->createEvent($this->timestamp, $license1, false);
$license2 = M::mock(ClearingLicense::classname());
$license2 = M::mock(ClearingLicense::class);
$license2->shouldReceive("getLicenseId")->withNoArgs()->andReturn($licBId);
$events[] = $this->createEvent($this->timestamp+60, $license2, false);
......@@ -127,11 +127,11 @@ class ClearingEventProcessorTest extends \PHPUnit\Framework\TestCase
{
$events = array();
$licId = 42;
$licenseRef1 = M::mock(ClearingLicense::classname());
$licenseRef1 = M::mock(ClearingLicense::class);
$licenseRef1->shouldReceive("getLicenseId")->withNoArgs()->andReturn($licId);
$events[] = $this->createEvent($this->timestamp, $licenseRef1, false);
$licenseRef2 = M::mock(ClearingLicense::classname());
$licenseRef2 = M::mock(ClearingLicense::class);
$licenseRef2->shouldReceive("getLicenseId")->withNoArgs()->andReturn($licId);
$events[] = $this->createEvent($this->timestamp+60, $licenseRef2, false);
......@@ -146,11 +146,11 @@ class ClearingEventProcessorTest extends \PHPUnit\Framework\TestCase
$events = array();
$licId = 42;
$licenseRef1 = M::mock(ClearingLicense::classname());
$licenseRef1 = M::mock(ClearingLicense::class);
$licenseRef1->shouldReceive("getLicenseId")->withNoArgs()->andReturn($licId);
$events[] = $this->createEvent($this->timestamp, $licenseRef1);
$licenseRef2 = M::mock(ClearingLicense::classname());
$licenseRef2 = M::mock(ClearingLicense::class);
$licenseRef2->shouldReceive("getLicenseId")->withNoArgs()->andReturn($licId);
$events[] = $this->createEvent($this->timestamp+60, $licenseRef2);
......@@ -164,11 +164,11 @@ class ClearingEventProcessorTest extends \PHPUnit\Framework\TestCase
{
$events = array();
$licenseRef1 = M::mock(ClearingLicense::classname());
$licenseRef1 = M::mock(ClearingLicense::class);
$licenseRef1->shouldReceive("getLicenseId")->withNoArgs()->andReturn("fortyTwo");
$events[] = $this->createEvent($this->timestamp, $licenseRef1);
$licenseRef2 = M::mock(ClearingLicense::classname());
$licenseRef2 = M::mock(ClearingLicense::class);
$licenseRef2->shouldReceive("getLicenseId")->withNoArgs()->andReturn("fortyTwo");
$events[] = $this->createEvent($this->timestamp+60, $licenseRef2);
......
......@@ -22,14 +22,13 @@ namespace Fossology\Lib\Dao;
use Fossology\Lib\Data\AgentRef;
use Fossology\Lib\Db\DbManager;
use Fossology\Lib\Util\Object;
use Monolog\Logger;
/**
* Class AgentDao
* @package Fossology\Lib\Dao
*/
class AgentDao extends Object
class AgentDao
{
const ARS_TABLE_SUFFIX = "_ars";
......@@ -318,4 +317,4 @@ class AgentDao extends Object
$row = $this->dbManager->getSingleRow("SELECT agent_rev FROM agent WHERE agent_enabled AND agent_pk=$1", array($agentId));
return ($row===false)?false:$row['agent_rev'];
}
}
\ No newline at end of file
}
......@@ -30,10 +30,9 @@ use Fossology\Lib\Data\LicenseRef;