23 use Symfony\Component\HttpFoundation\Request;
29 class ScanOptionsTest
extends \PHPUnit\Framework\TestCase
53 public function setUp() : void
56 $container = M::mock(
'ContainerBuilder');
57 $this->agentAdderMock = M::mock(
'overload:\AgentAdder');
58 $this->userDao = M::mock(UserDao::class);
59 $container->shouldReceive(
'get')->withArgs([
"dao.user"])
60 ->andReturn($this->userDao);
61 $container->shouldReceive(
'get')->andReturn(
null);
63 self::$functions = M::mock(\stdClass::class);
64 self::$functions->shouldReceive(
'FolderListUploads_perm')
70 self::$functions->shouldReceive(
'register_plugin')
71 ->with(\Hamcrest\Matchers::identicalTo(
72 new ScanOptions(
null,
null,
null,
null)));
82 private function prepareRequest($request, $reuserOpts, $deciderOpts)
84 if (!empty($reuserOpts)) {
85 $reuserSelector = $reuserOpts[
'upload'] .
"," . $reuserOpts[
'group'];
86 $request->request->set(
'uploadToReuse', $reuserSelector);
87 if (key_exists(
'rules', $reuserOpts)) {
88 $request->request->set(
'reuseMode', $reuserOpts[
'rules']);
91 if (!empty($deciderOpts)) {
92 $request->request->set(
'deciderRules', $deciderOpts);
93 if (in_array(
'nomosInMonk', $deciderOpts)) {
94 $request->request->set(
'Check_agent_nomos', 1);
112 $groupName =
"fossy";
113 $agentsToAdd = [
'agent_nomos',
'agent_ojo',
'agent_monk'];
115 'upload' => $reuseUploadId,
123 $request =
new Request();
124 $request = $this->
prepareRequest($request, $reuserOpts, $deciderOpts);
126 $analysis =
new Analysis();
127 $analysis->setUsingString(
"nomos,ojo,monk");
129 $reuse =
new Reuser($reuseUploadId, $groupName);
131 $decider =
new Decider();
132 $decider->setOjoDecider(
true);
133 $decider->setNomosMonk(
true);
134 $decider->setConcludeLicenseType(
"Permissive");
136 $scancode =
new Scancode();
138 $scanOption =
new ScanOptions($analysis, $reuse, $decider, $scancode);
140 $this->userDao->shouldReceive(
'getGroupIdByName')
141 ->withArgs([$groupName])->andReturn($groupId);
142 $this->agentAdderMock->shouldReceive(
'scheduleAgents')
146 $scanOption->scheduleAgents($folderId, $uploadId);
151 namespace Fossology\UI\Api\Models
153 function register_plugin($obj)
155 return \Fossology\Ui\Api\Test\Models\ScanOptionsTest::$functions
156 ->register_plugin($obj);
161 return \Fossology\Ui\Api\Test\Models\ScanOptionsTest::$functions
162 ->FolderListUploads_perm($parentFolder, $perm);
Contains the constants and helpers for authentication of user.
Model to hold analysis settings.
Model to hold info required by Reuser agent.
Model to hold add settings for new scan.
setUp()
Setup test objects.
prepareRequest($request, $reuserOpts, $deciderOpts)
FolderListUploads_perm($ParentFolder, $perm)
Returns an array of uploads in a folder.