27 require_once(__DIR__ .
'/../../agent/spdx2utils.php');
43 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
52 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
77 $args = array(
"key1" =>
"value");
90 $args = array(
"key1" =>
"value --key2=anotherValue");
92 assertThat($result[
"key1"], equalTo(
"value"));
93 assertThat($result[
"key2"], equalTo(
"anotherValue"));
113 $constTrue =
function ($licId){
116 $constFalse =
function ($licId){
121 'null' => array(
"LIC1", null,
"LIC1"),
123 'const true' => array(
"LIC1", $constTrue,
"LIC1"),
149 $constTrue =
function ($licId)
153 $constFalse =
function ($licId)
159 'single with null' => array(array(
"LIC1"), null, array(
"LIC1")),
160 'single with const false' => array(array(
"LIC1"), $constFalse, array(
SpdxTwoUtils::$prefix .
"LIC1")),
161 'single with const true' => array(array(
"LIC1"), $constTrue, array(
"LIC1")),
162 'multiple with null' => array(array(
"LIC1",
"LIC2",
"LIC3"), null, array(
"LIC1",
"LIC2",
"LIC3")),
163 'multiple with const false' => array(array(
"LIC1",
"LIC2",
"LIC3"),
166 'multiple with const true' => array(array(
"LIC1",
"LIC2",
"LIC3"), $constTrue, array(
"LIC1",
"LIC2",
"LIC3")),
167 'two licenses with one prefix (A)' => array(array(
"LIC1",
"LIC2"),
170 return $licId ===
'LIC2';
172 'two licenses with one prefix (2)' => array(array(
"LIC1",
"LIC2"),
175 return $licId ===
'LIC1';
198 $constTrue =
function ($licId)
202 $constFalse =
function ($licId)
208 'null' => array(null, $constTrue,
''),
209 'empty array' => array(array(), $constTrue,
''),
210 'empty array but prefix' => array(array(), $constFalse,
''),
211 'single license' => array(array(
"LIC1"), $constTrue,
'LIC1'),
212 'multiple licenses' => array(array(
"LIC1",
"LIC2",
"LIC3"), $constTrue,
'LIC1 AND LIC2 AND LIC3'),
213 'dual license 1st pos' => array(array(
"Dual-license",
"LIC2",
"LIC3"), $constTrue,
'LIC2 OR LIC3'),
214 'dual license 2nd pos' => array(array(
"LIC1",
"Dual-license",
"LIC3"), $constTrue,
'LIC1 OR LIC3'),
215 'dual license 3rd pos' => array(array(
"LIC1",
"LIC2",
"Dual-license"), $constTrue,
'LIC1 OR LIC2'),
216 'dual license with prefix' => array(array(
"LIC1",
"LIC2",
"Dual-license"),
219 return $licId ===
'LIC2';
221 'dual license with prefix' => array(array(
"LIC1",
"LIC2",
"Dual-license"),
224 return $licId ===
'LIC1';
225 },
'LIC1 OR '.SpdxTwoUtils::$prefix.
'LIC2'),
226 'dual license with prefix ($constFalse)' => array(array(
"LIC1",
"LIC2",
"Dual-license"),
228 'multiple dualLicense' => array(array(
"LIC1",
"LIC2 OR LIC3"), $constTrue,
'(LIC2 OR LIC3) AND LIC1'),
229 'multiple dualLicense with prefix' => array(array(
"LIC1",
"LIC2 OR LIC3"),
230 $constFalse,
'(LIC2 OR LIC3) AND '.SpdxTwoUtils::$prefix.
'LIC1'),
231 'dual multi license' => array(array(
"LIC1",
"LIC2 OR LIC3",
"Dual-license"), $constTrue,
'(LIC2 OR LIC3) OR LIC1'),
232 'dual multi license with prefix' => array(array(
"LIC1",
"LIC2 OR LIC3",
"Dual-license"),
233 $constFalse,
'(LIC2 OR LIC3) OR '.SpdxTwoUtils::$prefix.
'LIC1'),
testAddPrefixOnDemand($licenseId, $checker, $expected)
Test addPrefixOnDemand() provideLicenseSetAddPrefixOnDemand.
provideLicenseSetAddPrefixOnDemandList()
Prefix provider for license list.
testPreWorkOnArgsFlpRealWork()
Test preWorkOnArgsFlp() with actual format.
static preWorkOnArgsFlp($args, $key1, $key2)
For a given set of arguments assign $args[$key1] and $args[$key2].
testAddPrefixOnDemandNoChecker()
Test addPrefixOnDemand() with no check.
provideLicenseSetAddPrefixOnDemand()
Prefix provider for licenses.
testImplodeLicenses($lics, $prefix, $expected)
Test implodeLicenses() provideLicenseSetImplodeLicenses.
static addPrefixOnDemand($license, $spdxValidityChecker=null)
Add prefix to the license based on SPDX2 standards.
$assertCountBefore
Assertion count.
testPreWorkOnArgsFlpId()
Test preWorkOnArgsFlp() with args containing only key1.
Namespace used by SPDX2 agent.
testPreWorkOnArgsFlpZero()
Test preWorkOnArgsFlp() with empty array.
provideLicenseSetImplodeLicenses()
Prefix provider for license implode.
static addPrefixOnDemandList($licenses, $spdxValidityChecker=null)
Add prefix to license list.
testAddPrefixOnDemandList($licenseIds, $checker, $expected)
Test for addPrefixOnDemandList() provideLicenseSetAddPrefixOnDemandList.
static $prefix
Prefix to be used.
tearDown()
Tear down test env.
static implodeLicenses($licenses, $spdxValidityChecker=null)
Implode licenses with "AND" or "OR".