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 echo dirname(dirname(dirname(dirname(__DIR__)))) .
135 "/spdx2/agent_tests/Functional/fo_report.sql";
136 $this->testDb->createPlainTables([
'license_ref',
'license_file']);
137 $this->testDb->insertData([
'license_ref',
'license_file']);
139 $expectedFirstFinding = [
143 $expectedSecondFinding = [
144 'Classpath-exception-2.0',
147 $expectedThirdFinding = [
150 $expectedNoFinding = [];
152 $actualFirstFinding = $this->pfileDao->getScannerFindings(11);
153 $actualSecondFinding = $this->pfileDao->getScannerFindings(14);
154 $actualThirdFinding = $this->pfileDao->getScannerFindings(15);
155 $actualNoFinding = $this->pfileDao->getScannerFindings(12);
157 $this->assertEquals($expectedFirstFinding, $actualFirstFinding);
158 $this->assertEquals($expectedSecondFinding, $actualSecondFinding);
159 $this->assertEquals($expectedThirdFinding, $actualThirdFinding);
160 $this->assertEquals($expectedNoFinding, $actualNoFinding);
171 $this->testDb->createPlainTables([
'upload']);
172 $this->testDb->insertData([
'upload']);
174 $expectedSingleUpload = [1];
175 $expectedMultipleUploads = [2, 3];
176 $expectedNoUpload =
null;
178 $actualSingleUpload = $this->pfileDao->getUploadForPackage(1);
179 $actualMultipleUploads = $this->pfileDao->getUploadForPackage(9);
180 $actualNoUpload = $this->pfileDao->getUploadForPackage(99);
182 $this->assertEquals($expectedSingleUpload, $actualSingleUpload);
183 $this->assertEquals($expectedMultipleUploads, $actualMultipleUploads);
184 $this->assertEquals($expectedNoUpload, $actualNoUpload);
197 $this->testDb->createPlainTables([
'clearing_decision',
198 'clearing_decision_event',
'clearing_event',
'license_ref']);
199 $this->testDb->insertData([
'clearing_decision',
'clearing_decision_event',
200 'clearing_event',
'license_ref'],
false, SPDX_TEST_DATA);
202 $expectedLocalConclusion = [
'lic A'];
203 $expectedGlobalConclusion = [
'lic B'];
204 $expectedAllRemoval = [
"NONE"];
205 $expectedNoConclusion = [
"NOASSERTION"];
207 $actualLocalConclusion = $this->pfileDao->getConclusions(2, 2);
208 $actualGlobalConclusion = $this->pfileDao->getConclusions(4, 3);
209 $actualNoConclusions = $this->pfileDao->getConclusions(2, 7);
210 $actualAllRemoval = $this->pfileDao->getConclusions(2, 6);
212 $this->assertEquals($expectedLocalConclusion, $actualLocalConclusion);
213 $this->assertEquals($expectedGlobalConclusion, $actualGlobalConclusion);
214 $this->assertEquals($expectedNoConclusion, $actualNoConclusions);
215 $this->assertEquals($expectedAllRemoval, $actualAllRemoval);
228 $this->testDb->createPlainTables([
'copyright',
'copyright_decision']);
229 $this->testDb->insertData([
'copyright',
'copyright_decision']);
231 $expectedFirstFinding = [
232 'copyright (c) 2048',
233 'copyright (c) manual'
235 $expectedSecondFinding = [
236 'copyright (c) 2002 lawrence e. rosen. all rights
237 reserved. permission is hereby granted to copy and distribute this
239 'copyright grant to the software. the
240 bsd and apache licenses are vague and incomplete in that respect.
242 'copyright to the license will control changes. the apache
245 $expectedThirdFinding = [
246 'copyright (c) independent manual'
248 $expectedNoFinding = [];
250 $actualFirstFinding = $this->pfileDao->getCopyright(9);
251 $actualSecondFinding = $this->pfileDao->getCopyright(6);
252 $actualThirdFinding = $this->pfileDao->getCopyright(14);
253 $actualNoFinding = $this->pfileDao->getCopyright(15);
255 $this->assertEquals($expectedFirstFinding, $actualFirstFinding);
256 $this->assertEquals($expectedSecondFinding, $actualSecondFinding);
257 $this->assertEquals($expectedThirdFinding, $actualThirdFinding);
258 $this->assertEquals($expectedNoFinding, $actualNoFinding);
268 $this->testDb->createPlainTables([
'clearing_decision']);
269 $this->testDb->insertData([
'clearing_decision'],
false, SPDX_TEST_DATA);
270 $result = $this->pfileDao->haveConclusions(2, 2);
271 $this->assertTrue($result);
281 $this->testDb->createPlainTables([
'clearing_decision']);
282 $this->testDb->insertData([
'clearing_decision'],
false, SPDX_TEST_DATA);
283 $result = $this->pfileDao->haveConclusions(100, 100);
284 $this->assertFalse($result);
testHaveConclusionsFalse()
testHaveConclusionsTrue()
testGetUploadForPackage()
fo_dbManager * dbManager
fo_dbManager object