22 include_once(__DIR__.
'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
23 include_once(__DIR__.
'/SchedulerTestRunner.php');
25 include(dirname(dirname(__DIR__)).
'/agent/ReuserAgent.php');
81 public function run($uploadId, $userId=2, $groupId=2, $jobId=1, $args=
"")
83 $GLOBALS[
'userId'] = $userId;
84 $GLOBALS[
'jobId'] = $jobId;
85 $GLOBALS[
'groupId'] = $groupId;
89 $this->clearingEventProcessor = M::mock(LicenseRef::class);
90 $this->decisionTypes = M::mock(LicenseRef::class);
91 $this->agentLicenseEventProcessor = M::mock(LicenseRef::class);
93 $container = M::mock(
'Container');
94 $container->shouldReceive(
'get')->with(
'db.manager')->andReturn($this->
dbManager);
95 $container->shouldReceive(
'get')->with(
'dao.agent')->andReturn($this->agentDao);
96 $container->shouldReceive(
'get')->with(
'dao.clearing')->andReturn($this->clearingDao);
97 $container->shouldReceive(
'get')->with(
'dao.copyright')->andReturn($this->copyrightDao);
98 $container->shouldReceive(
'get')->with(
'dao.upload')->andReturn($this->uploadDao);
99 $container->shouldReceive(
'get')->with(
'decision.types')->andReturn($this->decisionTypes);
100 $container->shouldReceive(
'get')->with(
'businessrules.clearing_event_processor')->andReturn($this->clearingEventProcessor);
101 $container->shouldReceive(
'get')->with(
'businessrules.clearing_decision_filter')->andReturn($this->clearingDecisionFilter);
102 $container->shouldReceive(
'get')->with(
'businessrules.clearing_decision_processor')->andReturn($this->clearingDecisionProcessor);
103 $container->shouldReceive(
'get')->with(
'businessrules.agent_license_event_processor')->andReturn($this->agentLicenseEventProcessor);
104 $container->shouldReceive(
'get')->with(
'dao.tree')->andReturn($this->treeDao);
105 $GLOBALS[
'container'] = $container;
107 $fgetsMock = M::mock(\Fossology\Lib\
Agent\FgetsMock::class);
108 $fgetsMock->shouldReceive(
"fgets")->with(STDIN)->andReturn($uploadId,
false);
109 $GLOBALS[
'fgetsMock'] = $fgetsMock;
115 include(dirname(dirname(__DIR__)).
'/agent/reuser.php');
117 $output = ob_get_clean();
119 return array(
true, $output, $exitval);
Structure of an Agent with all required parameters.
Various utility functions to filter ClearingDecision.
Utility functions to process ClearingDecision.
Create mock objects for reuser.
$clearingDecisionProcessor
run($uploadId, $userId=2, $groupId=2, $jobId=1, $args="")
Function to run agent from scheduler.
fo_dbManager * dbManager
fo_dbManager object
Namespace to hold test cases for Reuser agent.