FOSSology  4.5.1
Open Source License Compliance by Open Source Software
LicenseCandidateTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2025 Harshit Gandhi <gandhiharshit716@gmail.com>
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
14 
16 use PHPUnit\Framework\TestCase;
17 
22 class LicenseCandidateTest extends TestCase
23 {
25  private $license;
26 
30  protected function setUp(): void
31  {
32  $this->license = new LicenseCandidate(
33  1,
34  'GPL-2.0',
35  'GPL-2.0-only',
36  'GNU General Public License 2.0',
37  'Sample license text',
38  'TestGroup',
39  101
40  );
41  }
42 
48  public function testConstructor()
49  {
50  $this->assertInstanceOf(LicenseCandidate::class, $this->license);
51  }
52 
54 
59  public function testGetId()
60  {
61  $this->assertEquals(1, $this->license->getId());
62  }
63 
68  public function testGetShortname()
69  {
70  $this->assertEquals('GPL-2.0', $this->license->getShortname());
71  }
72 
77  public function testGetSpdxid()
78  {
79  $this->assertEquals('GPL-2.0-only', $this->license->getSpdxid());
80  }
81 
86  public function testGetFullname()
87  {
88  $this->assertEquals('GNU General Public License 2.0', $this->license->getFullname());
89  }
90 
95  public function testGetText()
96  {
97  $this->assertEquals('Sample license text', $this->license->getText());
98  }
99 
104  public function testGetGroupName()
105  {
106  $this->assertEquals('TestGroup', $this->license->getGroupName());
107  }
108 
113  public function testGetGroupId()
114  {
115  $this->assertEquals(101, $this->license->getGroupId());
116  }
117 
119 
124  public function testSetId()
125  {
126  $this->license->setId(2);
127  $this->assertEquals(2, $this->license->getId());
128  }
129 
134  public function testSetShortname()
135  {
136  $this->license->setShortname('MIT');
137  $this->assertEquals('MIT', $this->license->getShortname());
138  }
139 
144  public function testSetSpdxid()
145  {
146  $this->license->setSpdxid('MIT');
147  $this->assertEquals('MIT', $this->license->getSpdxid());
148  }
149 
154  public function testSetFullname()
155  {
156  $this->license->setFullname('MIT License');
157  $this->assertEquals('MIT License', $this->license->getFullname());
158  }
159 
164  public function testSetText()
165  {
166  $this->license->setText('MIT sample text');
167  $this->assertEquals('MIT sample text', $this->license->getText());
168  }
169 
174  public function testSetGroupName()
175  {
176  $this->license->setGroupName('NewGroup');
177  $this->assertEquals('NewGroup', $this->license->getGroupName());
178  }
179 
184  public function testSetGroupId()
185  {
186  $this->license->setGroupId(202);
187  $this->assertEquals(202, $this->license->getGroupId());
188  }
189 }
Definition: nomos.h:426