9 namespace Fossology\Lib\Dao;
19 define(
"SPDX_TEST_DATA", dirname(dirname(dirname(dirname(__DIR__)))) .
20 "/spdx2/agent_tests/Functional/fo_report.sql");
48 protected function setUp() : void
50 $this->testDb =
new TestPgDb(
"pfiledao");
51 $this->
dbManager = $this->testDb->getDbManager();
52 $this->logger =
new Logger(
"test");
54 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
63 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount() -
64 $this->assertCountBefore);
65 $this->testDb->fullDestruct();
79 $this->testDb->createPlainTables([
'pfile']);
80 $this->testDb->insertData([
'pfile']);
84 'pfile_md5' =>
'E7295A5773D0EA17D53CBE6293924DD4',
85 'pfile_sha1' =>
'93247C8DB814F0A224B75B522C1FA4DC92DC3078',
86 'pfile_sha256' =>
'E29ABC32DB8B6241D598BC7C76681A7623D176D85F99E738A56C0CB684C367E1',
87 'pfile_size' => 10240,
88 'pfile_mimetypefk' => 12
92 'pfile_md5' =>
'E35086757EE4F4B35B0B1C63107DE47F',
93 'pfile_sha1' =>
'678C8AE6FC318346D61D540D30AA4ACE024BBB8B',
94 'pfile_sha256' =>
null,
96 'pfile_mimetypefk' => 30
100 'pfile_md5' =>
'95405535F6607638FC8B344F369D8CA9',
101 'pfile_sha1' =>
'FBE3181FD0ADDBD6E64B1FF6CAE1223A7DACB836',
102 'pfile_sha256' =>
'77949BC4E251CF4F0BAD9C5DC8C44C5803BC50A7E73F3B5DCAF985DEBE0E93B4',
104 'pfile_mimetypefk' => null
106 $notFoundPfile =
null;
108 $validPfileSha1 = $this->pfileDao
109 ->getPfile(
"93247C8DB814F0A224B75B522C1FA4DC92DC3078");
110 $validPfileMd5 = $this->pfileDao
111 ->getPfile(
null,
"e35086757ee4f4b35b0b1c63107de47f");
112 $validPfileSha1Sha256 = $this->pfileDao
113 ->getPfile(
"FBE3181FD0ADDBD6E64B1FF6CAE1223A7DACB836",
null,
114 "77949bc4e251cf4f0bad9c5dc8c44c5803bc50a7e73f3b5dcaf985debe0e93b4");
115 $invalidPfileSha1 = $this->pfileDao
116 ->getPfile(
"E47AA02935A589FADA86489705E0E0F0");
118 $this->assertEquals($pfileSha1, $validPfileSha1);
119 $this->assertEquals($pfileMd5, $validPfileMd5);
120 $this->assertEquals($pfileSha1Sha256, $validPfileSha1Sha256);
121 $this->assertEquals($notFoundPfile, $invalidPfileSha1);
134 $this->testDb->createPlainTables([
'license_ref',
'license_file']);
135 $this->testDb->insertData([
'license_ref',
'license_file']);
137 $expectedFirstFinding = [
141 $expectedSecondFinding = [
142 'Classpath-exception-2.0',
145 $expectedThirdFinding = [
148 $expectedNoFinding = [];
150 $actualFirstFinding = $this->pfileDao->getScannerFindings(11);
151 $actualSecondFinding = $this->pfileDao->getScannerFindings(14);
152 $actualThirdFinding = $this->pfileDao->getScannerFindings(15);
153 $actualNoFinding = $this->pfileDao->getScannerFindings(12);
155 $this->assertEquals($expectedFirstFinding, $actualFirstFinding);
156 $this->assertEquals($expectedSecondFinding, $actualSecondFinding);
157 $this->assertEquals($expectedThirdFinding, $actualThirdFinding);
158 $this->assertEquals($expectedNoFinding, $actualNoFinding);
169 $this->testDb->createPlainTables([
'upload']);
170 $this->testDb->insertData([
'upload']);
172 $expectedSingleUpload = [1];
173 $expectedMultipleUploads = [2, 3];
174 $expectedNoUpload =
null;
176 $actualSingleUpload = $this->pfileDao->getUploadForPackage(1);
177 $actualMultipleUploads = $this->pfileDao->getUploadForPackage(9);
178 $actualNoUpload = $this->pfileDao->getUploadForPackage(99);
180 $this->assertEquals($expectedSingleUpload, $actualSingleUpload);
181 $this->assertEquals($expectedMultipleUploads, $actualMultipleUploads);
182 $this->assertEquals($expectedNoUpload, $actualNoUpload);
195 $this->testDb->createPlainTables([
'clearing_decision',
196 'clearing_decision_event',
'clearing_event',
'license_ref']);
197 $this->testDb->insertData([
'clearing_decision',
'clearing_decision_event',
198 'clearing_event',
'license_ref'],
false, SPDX_TEST_DATA);
200 $expectedLocalConclusion = [
'lic A'];
201 $expectedGlobalConclusion = [
'lic B'];
202 $expectedAllRemoval = [
"NONE"];
203 $expectedNoConclusion = [
"NOASSERTION"];
205 $actualLocalConclusion = $this->pfileDao->getConclusions(2, 2);
206 $actualGlobalConclusion = $this->pfileDao->getConclusions(4, 3);
207 $actualNoConclusions = $this->pfileDao->getConclusions(2, 7);
208 $actualAllRemoval = $this->pfileDao->getConclusions(2, 6);
210 $this->assertEquals($expectedLocalConclusion, $actualLocalConclusion);
211 $this->assertEquals($expectedGlobalConclusion, $actualGlobalConclusion);
212 $this->assertEquals($expectedNoConclusion, $actualNoConclusions);
213 $this->assertEquals($expectedAllRemoval, $actualAllRemoval);
226 $this->testDb->createPlainTables([
'copyright',
'copyright_decision']);
227 $this->testDb->insertData([
'copyright',
'copyright_decision']);
229 $expectedFirstFinding = [
230 'copyright (c) 2048',
231 'copyright (c) manual'
233 $expectedSecondFinding = [
234 'copyright (c) 2002 lawrence e. rosen. all rights
235 reserved. permission is hereby granted to copy and distribute this
237 'copyright grant to the software. the
238 bsd and apache licenses are vague and incomplete in that respect.
240 'copyright to the license will control changes. the apache
243 $expectedThirdFinding = [
244 'copyright (c) independent manual'
246 $expectedNoFinding = [];
248 $actualFirstFinding = $this->pfileDao->getCopyright(9);
249 $actualSecondFinding = $this->pfileDao->getCopyright(6);
250 $actualThirdFinding = $this->pfileDao->getCopyright(14);
251 $actualNoFinding = $this->pfileDao->getCopyright(15);
253 $this->assertEquals($expectedFirstFinding, $actualFirstFinding);
254 $this->assertEquals($expectedSecondFinding, $actualSecondFinding);
255 $this->assertEquals($expectedThirdFinding, $actualThirdFinding);
256 $this->assertEquals($expectedNoFinding, $actualNoFinding);
testGetUploadForPackage()
fo_dbManager * dbManager
fo_dbManager object