16 use PHPUnit\Framework\TestCase;
32 'first_rf_fk' =>
"306",
33 'second_rf_fk' =>
null,
34 'first_rf_shortname' =>
"MIT",
35 'second_rf_shortname' =>
null,
36 'first_type' =>
"Permissive",
37 'second_type' =>
"Strong Copyleft",
38 'comment' =>
"A permissive license is compatible with a copyleft license",
39 'compatibility' =>
"t"
50 "Permissive",
"Strong Copyleft",
51 "A permissive license is compatible with a copyleft license",
true);
60 $this->assertInstanceOf(LicenseCompatibilityRule::class, $this->
getRule());
72 $this->assertSame(4, $rule->getId());
73 $this->assertSame(306, $rule->getFirstLicenseId());
74 $this->assertEquals(
"MIT", $rule->getFirstLicenseName());
75 $this->assertNull($rule->getSecondLicenseId());
76 $this->assertNull($rule->getSecondLicenseName());
77 $this->assertEquals(
"Permissive", $rule->getFirstType());
78 $this->assertEquals(
"Strong Copyleft", $rule->getSecondType());
80 "A permissive license is compatible with a copyleft license",
82 $this->assertTrue($rule->getCompatibility());
93 $row[
'compatibility'] =
"f";
108 $rule->setFirstLicenseId(188);
109 $rule->setFirstLicenseName(
"GPL-2.0-only");
110 $rule->setSecondLicenseId(306);
111 $rule->setSecondLicenseName(
"MIT");
112 $rule->setFirstType(
"Strong Copyleft");
113 $rule->setSecondType(
"Permissive");
114 $rule->setComment(
"New description");
115 $rule->setCompatibility(
false);
117 $this->assertEquals(5, $rule->getId());
118 $this->assertEquals(188, $rule->getFirstLicenseId());
119 $this->assertEquals(
"GPL-2.0-only", $rule->getFirstLicenseName());
120 $this->assertEquals(306, $rule->getSecondLicenseId());
121 $this->assertEquals(
"MIT", $rule->getSecondLicenseName());
122 $this->assertEquals(
"Strong Copyleft", $rule->getFirstType());
123 $this->assertEquals(
"Permissive", $rule->getSecondType());
124 $this->assertEquals(
"New description", $rule->getComment());
125 $this->assertFalse($rule->getCompatibility());
137 'first_license_id' => 306,
138 'first_license_name' =>
"MIT",
139 'second_license_id' =>
null,
140 'second_license_name' =>
null,
141 'first_type' =>
"Permissive",
142 'second_type' =>
"Strong Copyleft",
143 'comment' =>
"A permissive license is compatible with a copyleft license",
144 'compatibility' => true
147 $this->assertEquals($expected,
148 $this->
getRule()->getArray(ApiVersion::V1));
160 'firstLicenseId' => 306,
161 'firstLicenseName' =>
"MIT",
162 'secondLicenseId' =>
null,
163 'secondLicenseName' =>
null,
164 'firstType' =>
"Permissive",
165 'secondType' =>
"Strong Copyleft",
166 'comment' =>
"A permissive license is compatible with a copyleft license",
167 'compatibility' => true
170 $this->assertEquals($expected,
171 $this->
getRule()->getArray(ApiVersion::V2));
183 $this->assertEquals(json_encode($rule->getArray(ApiVersion::V2)),
184 $rule->getJSON(ApiVersion::V2));
Model to hold a single license compatibility rule.
Tests for LicenseCompatibilityRule model.
getRule()
Get a new model object holding the values of getRuleRow()
getRuleRow()
Get a rule row as returned by CompatibilityDao.
testFromArrayWithFalseCompatibility()