FOSSology  4.5.1
Open Source License Compliance by Open Source Software
BulkHistoryTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  SPDX-FileCopyrightText: © 2024 Valens Niyonsenga <valensniyonsenga2003@gmail.com>
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 
15 use PHPUnit\Framework\TestCase;
16 
17 class BulkHistoryTest extends TestCase
18 {
19 
21 
27  public function testConstructor()
28  {
29  $bulkHistory = new BulkHistory(
30  101,
31  202,
32  'Scan reference text',
33  true,
34  false,
35  ['License A', 'License B'],
36  ['License C']
37  );
38  $this->assertInstanceOf(BulkHistory::class, $bulkHistory);
39  }
40 
48  private function getBulkHistoryInfo()
49  {
50  $expectedArray = [
51  "bulkId" => 4,
52  "clearingEventId" => 3,
53  "text" => "BulkHistory text",
54  "matched" => false,
55  "tried" => false,
56  "addedLicenses" => [],
57  "removedLicenses" => []
58  ];
59  $obj = new BulkHistory(4, 3, "BulkHistory text", false, false, [], []);
60  return [
61  'expectedArray' => $expectedArray,
62  'obj' => $obj
63  ];
64  }
65 
71  public function testDataFormat()
72  {
73  $expectedArray = $this->getBulkHistoryInfo()['expectedArray'];
74  $bulkHistory = $this->getBulkHistoryInfo()['obj'];
75  $this->assertEquals($expectedArray, $bulkHistory->getArray());
76  }
77 
84  public function testSetAndGetBulkId()
85  {
86  $info = $this->getBulkHistoryInfo();
87  $bulkHistory = $info['obj'];
88  $bulkId = 5;
89  $bulkHistory->setBulkId($bulkId);
90  $this->assertEquals($bulkId, $bulkHistory->getBulkId());
91  }
92 
99  public function testSetAndGetClearingEventId()
100  {
101  $info = $this->getBulkHistoryInfo();
102  $bulkHistory = $info['obj'];
103  $clearingEventId = 6;
104  $bulkHistory->setClearingEventId($clearingEventId);
105  $this->assertEquals($clearingEventId, $bulkHistory->getClearingEventId());
106  }
107 
114  public function testSetAndGetText()
115  {
116  $info = $this->getBulkHistoryInfo();
117  $bulkHistory = $info['obj'];
118  $text = "Updated text";
119  $bulkHistory->setText($text);
120  $this->assertEquals($text, $bulkHistory->getText());
121  }
122 
129  public function testSetAndGetMatched()
130  {
131  $info = $this->getBulkHistoryInfo();
132  $bulkHistory = $info['obj'];
133  $matched = true;
134  $bulkHistory->setMatched($matched);
135  $this->assertEquals($matched, $bulkHistory->getMatched());
136  }
137 
144  public function testSetAndGetTried()
145  {
146  $info = $this->getBulkHistoryInfo();
147  $bulkHistory = $info['obj'];
148  $tried = true;
149  $bulkHistory->setTried($tried);
150  $this->assertEquals($tried, $bulkHistory->getTried());
151  }
152 
159  public function testSetAndGetAddedLicenses()
160  {
161  $info = $this->getBulkHistoryInfo();
162  $bulkHistory = $info['obj'];
163  $addedLicenses = ['LicenseA', 'LicenseB'];
164  $bulkHistory->setAddedLicenses($addedLicenses);
165  $this->assertEquals($addedLicenses, $bulkHistory->getAddedLicenses());
166  }
167 
175  {
176  $info = $this->getBulkHistoryInfo();
177  $bulkHistory = $info['obj'];
178  $removedLicenses = ['LicenseX', 'LicenseY'];
179  $bulkHistory->setRemovedLicenses($removedLicenses);
180  $this->assertEquals($removedLicenses, $bulkHistory->getRemovedLicenses());
181  }
182 }