20 include_once(__DIR__.
'/../../../lib/php/Test/Agent/AgentTestMockHelper.php');
21 include_once(__DIR__.
'/SchedulerTestRunner.php');
23 include_once(dirname(dirname(__DIR__)).
'/agent/DeciderJobAgent.php');
36 private $clearingDecisionProcessor;
38 private $agentLicenseEventProcessor;
44 private $decisionTypes;
46 private $highlightDao;
51 $this->clearingDao = $clearingDao;
52 $this->agentDao = $agentDao;
53 $this->uploadDao = $uploadDao;
54 $this->highlightDao = $highlightDao;
57 $this->clearingDecisionProcessor = $clearingDecisionProcessor;
58 $this->agentLicenseEventProcessor = $agentLicenseEventProcessor;
70 public function run($uploadId, $userId=2, $groupId=2, $jobId=1, $args=
"")
72 $GLOBALS[
'userId'] = $userId;
73 $GLOBALS[
'jobId'] = $jobId;
74 $GLOBALS[
'groupId'] = $groupId;
79 if (preg_match(
"/-k([0-9]*)/", $args, $matches)) {
80 $opts[
'k'] = $matches[1];
83 $GLOBALS[
'extraOpts'] = $opts;
85 $container = M::mock(
'Container');
86 $container->shouldReceive(
'get')->with(
'db.manager')->andReturn($this->
dbManager);
87 $container->shouldReceive(
'get')->with(
'dao.agent')->andReturn($this->agentDao);
88 $container->shouldReceive(
'get')->with(
'dao.clearing')->andReturn($this->clearingDao);
89 $container->shouldReceive(
'get')->with(
'dao.upload')->andReturn($this->uploadDao);
90 $container->shouldReceive(
'get')->with(
'dao.highlight')->andReturn($this->highlightDao);
91 $container->shouldReceive(
'get')->with(
'decision.types')->andReturn($this->decisionTypes);
92 $container->shouldReceive(
'get')->with(
'businessrules.clearing_decision_processor')->andReturn($this->clearingDecisionProcessor);
93 $container->shouldReceive(
'get')->with(
'businessrules.agent_license_event_processor')->andReturn($this->agentLicenseEventProcessor);
94 $GLOBALS[
'container'] = $container;
96 $fgetsMock = M::mock(\Fossology\Lib\
Agent\FgetsMock::class);
97 $fgetsMock->shouldReceive(
"fgets")->with(STDIN)->andReturn($uploadId,
false);
98 $GLOBALS[
'fgetsMock'] = $fgetsMock;
104 include(dirname(dirname(__DIR__)).
'/agent/deciderjob.php');
106 $output = ob_get_clean();
108 return array(
true, $output, $exitval);
Mock for scheduler inputs.
run($uploadId, $userId=2, $groupId=2, $jobId=1, $args="")
Mock as agent was called from scheduler.
Structure of an Agent with all required parameters.
Handle events related to license findings.
Utility functions to process ClearingDecision.
Interface for scheduler. Called by test case.
fo_dbManager * dbManager
fo_dbManager object
Namespace for decider job test cases.