16 use PHPUnit\Framework\TestCase;
30 protected function setUp(): void
33 "ri_reviewed" =>
true,
34 "ri_footer" =>
"Test Footer",
35 "ri_report_rel" =>
"1.0.0",
36 "ri_community" =>
"Test Community",
37 "ri_component" =>
"Test Component",
38 "ri_version" =>
"1.0",
39 "ri_release_date" =>
"2025-02-15",
40 "ri_sw360_link" =>
"https://example.com",
41 "ri_component_type" => 1,
42 "ri_component_id" =>
"TEST-123",
43 "ri_general_assesment" =>
"Test Assessment",
44 "ri_ga_additional" =>
"Additional Notes",
45 "ri_ga_risk" =>
"Low",
46 "ri_ga_checkbox_selection" =>
"Option 1",
47 "ri_spdx_selection" =>
"MIT",
48 "ri_cyclonedx_selection" =>
'{"licenseComment":true,"ignoreFilesWithoutInfo":false,"osselotExport":false,"tagNamespace":"acme:","specVersion":"1.6"}',
49 "ri_excluded_obligations" => json_encode([
"obligation1",
"obligation2"]),
50 "ri_department" =>
"Test Department",
51 "ri_depnotes" =>
"Department Notes",
52 "ri_exportnotes" =>
"Export Notes",
53 "ri_copyrightnotes" =>
"Copyright Notes",
54 "ri_unifiedcolumns" => json_encode([
"col1",
"col2"]),
55 "ri_globaldecision" => 1
69 $this->assertInstanceOf(Conf::class, $conf);
78 $conf =
new Conf($this->sampleData);
79 $result = $conf->getArray();
81 $this->assertIsArray($result);
82 $this->assertEquals(
true, $result[
'reviewed']);
83 $this->assertEquals(
"Test Footer", $result[
'footer']);
84 $this->assertEquals(
"1.0.0", $result[
'reportRel']);
85 $this->assertEquals(
"Test Community", $result[
'community']);
86 $this->assertEquals(
"Test Component", $result[
'component']);
87 $this->assertEquals(
"1.0", $result[
'version']);
88 $this->assertEquals(
"2025-02-15", $result[
'releaseDate']);
89 $this->assertEquals(
"https://example.com", $result[
'sw360Link']);
91 $this->assertEquals(
"TEST-123", $result[
'componentId']);
92 $this->assertEquals(
"Test Assessment", $result[
'generalAssesment']);
93 $this->assertEquals(
"Additional Notes", $result[
'gaAdditional']);
94 $this->assertEquals(
"Low", $result[
'gaRisk']);
95 $this->assertEquals(
"Option 1", $result[
'gaCheckbox']);
96 $this->assertEquals(
"MIT", $result[
'spdxSelection']);
97 $this->assertEquals(
"acme:", $result[
'cyclonedxSelection'][
'tagNamespace']);
98 $this->assertEquals(
"1.6", $result[
'cyclonedxSelection'][
'specVersion']);
99 $this->assertTrue($result[
'cyclonedxSelection'][
'licenseComment']);
100 $this->assertEquals([
"obligation1",
"obligation2"], $result[
'excludedObligations']);
101 $this->assertEquals(
"Test Department", $result[
'department']);
102 $this->assertEquals(
"Department Notes", $result[
'depNotes']);
103 $this->assertEquals(
"Export Notes", $result[
'exportNotes']);
104 $this->assertEquals(
"Copyright Notes", $result[
'copyrightNotes']);
105 $this->assertEquals([
"col1",
"col2"], $result[
'unifiedColumns']);
106 $this->assertEquals(
true, $result[
'globalDecision']);
115 $conf =
new Conf($this->sampleData);
116 $result = $conf->getJSON();
118 $this->assertIsString($result);
119 $this->assertJson($result);
121 $decodedJson = json_decode($result,
true);
122 $this->assertEquals($conf->getArray(), $decodedJson);
133 $this->assertEquals(
"ri_reviewed", $conf->getKeyColumnName(
"reviewed"));
134 $this->assertEquals(
"ri_footer", $conf->getKeyColumnName(
"footer"));
135 $this->assertEquals(
"ri_component_type", $conf->getKeyColumnName(
"componentType"));
136 $this->assertEquals(
"ri_globaldecision", $conf->getKeyColumnName(
"globalDecision"));
147 $this->assertTrue($conf->doesKeyExist(
"reviewed"));
148 $this->assertTrue($conf->doesKeyExist(
"footer"));
149 $this->assertTrue($conf->doesKeyExist(
"componentType"));
150 $this->assertTrue($conf->doesKeyExist(
"globalDecision"));
161 $this->assertFalse($conf->doesKeyExist(
"invalidKey"));
162 $this->assertFalse($conf->doesKeyExist(
""));
163 $this->assertFalse($conf->doesKeyExist(
"123"));
Conf model to contain general error and return values.
testDoesKeyExistValidKeys()
testDoesKeyExistInvalidKeys()