public function run($uploadId, $userId = 2, $groupId = 2, $jobId = 1, $args = "") { $GLOBALS['userId'] = $userId; $GLOBALS['jobId'] = $jobId; $GLOBALS['groupId'] = $groupId; $matches = array(); $opts = array(); if (preg_match("/-r([0-9]*)/", $args, $matches)) { $opts['r'] = $matches[1]; } $GLOBALS['extraOpts'] = $opts; $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('dao.highlight')->andReturn($this->highlightDao); $container->shouldReceive('get')->with('decision.types')->andReturn($this->decisionTypes); $container->shouldReceive('get')->with('businessrules.clearing_decision_processor')->andReturn($this->clearingDecisionProcessor); $container->shouldReceive('get')->with('businessrules.agent_license_event_processor')->andReturn($this->agentLicenseEventProcessor); $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/decider.php'; $output = ob_get_clean(); return array(true, $output, $exitval); }
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); }