16 use PHPUnit\Framework\TestCase;
26 private $shortName =
"GPL-2.0";
28 private $spdxId =
"GPL-2.0-only";
39 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
40 $this->assertInstanceOf(EditedLicense::class, $license);
51 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
52 $this->assertEquals($this->
id, $license->getId());
61 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
62 $this->assertEquals($this->shortName, $license->getShortName());
71 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
72 $this->assertEquals($this->count, $license->getCount());
81 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
82 $this->assertEquals($this->spdxId, $license->getSpdxId());
93 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
95 $license->setId($newId);
96 $this->assertEquals($newId, $license->getId());
105 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
106 $newShortName =
"MIT";
107 $license->setShortName($newShortName);
108 $this->assertEquals($newShortName, $license->getShortName());
117 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
119 $license->setCount($newCount);
120 $this->assertEquals($newCount, $license->getCount());
129 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
131 $license->setSpdxId($newSpdxId);
132 $this->assertEquals($newSpdxId, $license->getSpdxId());
141 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
143 $license->setId(
null);
144 $this->assertNull($license->getId());
146 $license->setShortName(
null);
147 $this->assertNull($license->getShortName());
149 $license->setCount(
null);
150 $this->assertNull($license->getCount());
152 $license->setSpdxId(
null);
153 $this->assertNull($license->getSpdxId());
162 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
164 $license->setId(
"100");
165 $this->assertEquals(100, $license->getId());
167 $license->setCount(
"200");
168 $this->assertEquals(200, $license->getCount());
170 $license->setShortName(123);
171 $this->assertEquals(
"123", $license->getShortName());
173 $license->setSpdxId(456);
174 $this->assertEquals(
"456", $license->getSpdxId());
185 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
189 'shortName' => $this->shortName,
190 'count' => $this->count,
191 'spdx_id' => $this->spdxId
194 $this->assertEquals($expectedArray, $license->getArray(ApiVersion::V1));
203 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
207 'shortName' => $this->shortName,
208 'count' => $this->count,
209 'spdxId' => $this->spdxId
212 $this->assertEquals($expectedArray, $license->getArray(ApiVersion::V2));
221 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
223 $resultV1 = $license->getJSON(ApiVersion::V1);
224 $this->assertIsString($resultV1);
225 $this->assertJson($resultV1);
226 $this->assertEquals($license->getArray(ApiVersion::V1), json_decode($resultV1,
true));
235 $license =
new EditedLicense($this->
id, $this->shortName, $this->count, $this->spdxId);
237 $resultV2 = $license->getJSON(ApiVersion::V2);
238 $this->assertIsString($resultV2);
239 $this->assertJson($resultV2);
240 $this->assertEquals($license->getArray(ApiVersion::V2), json_decode($resultV2,
true));
Tests for EditedLicense model.
testSettersWithNullValues()
testSettersWithTypeConversion()