32 if (!function_exists(
'Traceback_uri'))
35 return 'Traceback_uri_if_desired';
76 $this->testDb =
new TestPgDb(
"copyrightSched".time());
77 $this->
dbManager = $this->testDb->getDbManager();
79 $logger =
new Logger(
"CopyrightSchedulerTest");
82 $this->uploadPermDao = \Mockery::mock(UploadPermissionDao::class);
93 $this->testDb->fullDestruct();
96 $this->licenseDao = null;
111 $sysConf = $this->testDb->getFossSysConf();
113 $agentName =
"copyright";
115 $agentDir = dirname(dirname(__DIR__));
116 $execDir =
"$agentDir/agent";
117 system(
"install -D $agentDir/VERSION-copyright $sysConf/mods-enabled/$agentName/VERSION");
118 system(
"install -D $agentDir/agent/copyright.conf $sysConf/mods-enabled/$agentName/agent/copyright.conf");
119 $pCmd =
"echo $uploadId | $execDir/$agentName -c $sysConf --scheduler_start";
120 $pipeFd = popen($pCmd,
"r");
121 $this->assertTrue($pipeFd !==
false,
'running copyright failed');
124 while (($buffer = fgets($pipeFd, 4096)) !==
false) {
127 $retCode = pclose($pipeFd);
129 unlink(
"$sysConf/mods-enabled/$agentName/VERSION");
130 unlink(
"$sysConf/mods-enabled/$agentName/agent/copyright.conf");
131 rmdir(
"$sysConf/mods-enabled/$agentName/agent/");
132 rmdir(
"$sysConf/mods-enabled/$agentName");
133 rmdir(
"$sysConf/mods-enabled");
134 unlink($sysConf.
"/fossology.conf");
136 $this->assertEquals($retCode, 0,
"copyright failed ($retCode): $output [$pCmd]");
145 $sysConf = $this->testDb->getFossSysConf();
147 $confFile = $sysConf.
"/fossology.conf";
148 system(
"touch ".$confFile);
149 $config =
"[FOSSOLOGY]\ndepth = 0\npath = $sysConf/repo\n";
150 file_put_contents($confFile, $config);
152 $testRepoDir = dirname(dirname(dirname(__DIR__))).
"/lib/php/Test/";
153 system(
"cp -a $testRepoDir/repo $sysConf/");
161 $sysConf = $this->testDb->getFossSysConf();
162 system(
"rm $sysConf/repo -rf");
170 $this->testDb->createPlainTables(array(
'agent',
'uploadtree',
'upload',
'pfile',
'users',
'bucketpool',
'mimetype',
'ars_master',
'author'));
171 $this->testDb->createSequences(array(
'agent_agent_pk_seq',
'upload_upload_pk_seq',
'pfile_pfile_pk_seq',
'users_user_pk_seq',
'nomos_ars_ars_pk_seq'));
172 $this->testDb->createConstraints(array(
'agent_pkey',
'upload_pkey_idx',
'pfile_pkey',
'user_pkey'));
173 $this->testDb->alterTables(array(
'agent',
'pfile',
'upload',
'ars_master',
'users'));
174 $this->testDb->createInheritedTables(array(
'uploadtree_a'));
176 $this->testDb->insertData(array(
'upload',
'pfile',
'uploadtree_a',
'bucketpool',
'mimetype',
'users'),
false);
195 $uploadTreeTableName = $this->uploadDao->getUploadtreeTableName($uploadId);
196 $matches = $this->copyrightDao->getAllEntries(
"copyright", $uploadId, $uploadTreeTableName);
197 $this->assertGreaterThan($expected=5, count($matches), $output);
Traceback_uri()
Get the URI without query to this location.
setUp()
Setup the test cases and initialize the objects.
setUpTables()
Setup tables required by copyright agent.
rmRepo()
Remove the test repo.
fo_dbManager * dbManager
fo_dbManager object
tearDown()
Destruct the objects initialized during setUp()
runCopyright($uploadId)
Run copyright on a given upload id.
Unit test cases for copyright agent using scheduler.
setUpRepo()
Setup test repo mimicking install.