FOSSology  4.5.0-rc1
Open Source License Compliance by Open Source Software
spdxutilTest.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\Spdx;
15 
16 require_once(__DIR__ . '/../../agent/spdxutils.php');
17 
22 class spdxutilTest 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(SpdxUtils::preWorkOnArgsFlp($args,"key1","key2"), equalTo($args));
55  }
56 
64  public function testPreWorkOnArgsFlpId()
65  {
66  $args = array("key1" => "value");
67  assertThat(SpdxUtils::preWorkOnArgsFlp($args,"key1","key2"), equalTo($args));
68  }
69 
77  public function testPreWorkOnArgsFlpRealWork()
78  {
79  $args = array("key1" => "value --key2=anotherValue");
80  $result = SpdxUtils::preWorkOnArgsFlp($args,"key1","key2");
81  assertThat($result["key1"], equalTo("value"));
82  assertThat($result["key2"], equalTo("anotherValue"));
83  }
84 
92  {
93  assertThat(SpdxUtils::addPrefixOnDemand("LIC1"), equalTo("LIC1"));
94  }
95 }
static preWorkOnArgsFlp($args, $key1, $key2)
For a given set of arguments assign $args[$key1] and $args[$key2].
Definition: spdxutils.php:28
static addPrefixOnDemand($license)
Add prefix to the license based on SPDX2 standards.
Definition: spdxutils.php:46
testPreWorkOnArgsFlpZero()
Test preWorkOnArgsFlp() with empty array.
tearDown()
Tear down test env.
testPreWorkOnArgsFlpRealWork()
Test preWorkOnArgsFlp() with actual format.
$assertCountBefore
Assertion count.
testAddPrefixOnDemandNoChecker()
Test addPrefixOnDemand() with no check.
testPreWorkOnArgsFlpId()
Test preWorkOnArgsFlp() with args containing only key1.
Namespace used by SPDX2 agent.