FOSSology  4.4.0
Open Source License Compliance by Open Source Software
spdx2utilTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2016 Siemens AG
4  SPDX-FileCopyrightText: © 2017 TNG Technology Consulting GmbH
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
14 namespace Fossology\SpdxTwo;
15 
16 require_once(__DIR__ . '/../../agent/spdx2utils.php');
17 
22 class spdx2utilTest extends \PHPUnit\Framework\TestCase
23 {
25 
30  protected function setUp() : void
31  {
32  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
33  }
34 
39  protected function tearDown() : void
40  {
41  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
42  }
43 
51  public function testPreWorkOnArgsFlpZero()
52  {
53  $args = array();
54  assertThat(SpdxTwoUtils::preWorkOnArgsFlp($args,"key1","key2"), equalTo($args));
55  }
56 
64  public function testPreWorkOnArgsFlpId()
65  {
66  $args = array("key1" => "value");
67  assertThat(SpdxTwoUtils::preWorkOnArgsFlp($args,"key1","key2"), equalTo($args));
68  }
69 
77  public function testPreWorkOnArgsFlpRealWork()
78  {
79  $args = array("key1" => "value --key2=anotherValue");
80  $result = SpdxTwoUtils::preWorkOnArgsFlp($args,"key1","key2");
81  assertThat($result["key1"], equalTo("value"));
82  assertThat($result["key2"], equalTo("anotherValue"));
83  }
84 
92  {
93  assertThat(SpdxTwoUtils::addPrefixOnDemand("LIC1"), equalTo("LIC1"));
94  }
95 }
static preWorkOnArgsFlp($args, $key1, $key2)
For a given set of arguments assign $args[$key1] and $args[$key2].
Definition: spdx2utils.php:28
static addPrefixOnDemand($license)
Add prefix to the license based on SPDX2 standards.
Definition: spdx2utils.php:46
testPreWorkOnArgsFlpId()
Test preWorkOnArgsFlp() with args containing only key1.
testPreWorkOnArgsFlpZero()
Test preWorkOnArgsFlp() with empty array.
testPreWorkOnArgsFlpRealWork()
Test preWorkOnArgsFlp() with actual format.
testAddPrefixOnDemandNoChecker()
Test addPrefixOnDemand() with no check.
tearDown()
Tear down test env.
Namespace used by SPDX2 agent.