FOSSology  4.4.0
Open Source License Compliance by Open Source Software
DeciderTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2020 Siemens AG
4  Author: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
14 
17 
22 class DeciderTest extends \PHPUnit\Framework\TestCase
23 {
30  public function testSetUsingArrayV1()
31  {
32  $this->testSetUsingArray(ApiVersion::V1);
33  }
34 
41  public function testSetUsingArrayV2()
42  {
43  $this->testSetUsingArray(ApiVersion::V2);
44  }
45 
51  private function testSetUsingArray($version)
52  {
53  if ($version == ApiVersion::V1) {
54  $deciderArray = [
55  "nomos_monk" => true,
56  "bulk_reused" => false,
57  "ojo_decider" => (1==1),
58  "conclude_license_type" => " Permissive "
59  ];
60  } else {
61  $deciderArray = [
62  "nomosMonk" => true,
63  "bulkReused" => false,
64  "ojoDecider" => (1==1),
65  "concludeLicenseType" => " Permissive "
66  ];
67  }
68 
69  $expectedObject = new Decider(true, false, false, true, "Permissive");
70 
71  $actualObject = new Decider();
72  $actualObject->setUsingArray($deciderArray, $version);
73 
74  $this->assertEquals($expectedObject, $actualObject);
75  }
76 
83  public function testDataFormatV1()
84  {
85  $this->testDataFormat(ApiVersion::V1);
86  }
87 
94  public function testDataFormatV2()
95  {
96  $this->testDataFormat(ApiVersion::V2);
97  }
98 
104  private function testDataFormat($version)
105  {
106  if ($version == ApiVersion::V1) {
107  $expectedArray = [
108  "nomos_monk" => true,
109  "bulk_reused" => false,
110  "new_scanner" => false,
111  "ojo_decider" => true,
112  "conclude_license_type" => "Permissive"
113  ];
114  } else {
115  $expectedArray = [
116  "nomosMonk" => true,
117  "bulkReused" => false,
118  "newScanner" => false,
119  "ojoDecider" => true,
120  "concludeLicenseType" => "Permissive"
121  ];
122  }
123 
124  $actualObject = new Decider();
125  $actualObject->setNomosMonk(true);
126  $actualObject->setOjoDecider(true);
127  $actualObject->setConcludeLicenseType(" Permissive ");
128 
129  $this->assertEquals($expectedArray, $actualObject->getArray($version));
130  }
131 }