FOSSology  4.4.0
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 {
26  private function getBulkHistoryInfo()
27  {
28  $expectedArray = [
29  "bulkId" => 4,
30  "clearingEventId" => 3,
31  "text" => "BulkHistory text",
32  "matched" => false,
33  "tried" => false,
34  "addedLicenses" => [],
35  "removedLicenses" => []
36  ];
37  $obj = new BulkHistory(4, 3, "BulkHistory text", false, false, [], []);
38  return [
39  'expectedArray' => $expectedArray,
40  'obj' => $obj
41  ];
42  }
43 
49  public function testDataFormat()
50  {
51  $expectedArray = $this->getBulkHistoryInfo()['expectedArray'];
52  $bulkHistory = $this->getBulkHistoryInfo()['obj'];
53  $this->assertEquals($expectedArray, $bulkHistory->getArray());
54  }
55 
62  public function testSetAndGetBulkId()
63  {
64  $info = $this->getBulkHistoryInfo();
65  $bulkHistory = $info['obj'];
66  $bulkId = 5;
67  $bulkHistory->setBulkId($bulkId);
68  $this->assertEquals($bulkId, $bulkHistory->getBulkId());
69  }
70 
77  public function testSetAndGetClearingEventId()
78  {
79  $info = $this->getBulkHistoryInfo();
80  $bulkHistory = $info['obj'];
81  $clearingEventId = 6;
82  $bulkHistory->setClearingEventId($clearingEventId);
83  $this->assertEquals($clearingEventId, $bulkHistory->getClearingEventId());
84  }
85 
92  public function testSetAndGetText()
93  {
94  $info = $this->getBulkHistoryInfo();
95  $bulkHistory = $info['obj'];
96  $text = "Updated text";
97  $bulkHistory->setText($text);
98  $this->assertEquals($text, $bulkHistory->getText());
99  }
100 
107  public function testSetAndGetMatched()
108  {
109  $info = $this->getBulkHistoryInfo();
110  $bulkHistory = $info['obj'];
111  $matched = true;
112  $bulkHistory->setMatched($matched);
113  $this->assertEquals($matched, $bulkHistory->getMatched());
114  }
115 
122  public function testSetAndGetTried()
123  {
124  $info = $this->getBulkHistoryInfo();
125  $bulkHistory = $info['obj'];
126  $tried = true;
127  $bulkHistory->setTried($tried);
128  $this->assertEquals($tried, $bulkHistory->getTried());
129  }
130 
137  public function testSetAndGetAddedLicenses()
138  {
139  $info = $this->getBulkHistoryInfo();
140  $bulkHistory = $info['obj'];
141  $addedLicenses = ['LicenseA', 'LicenseB'];
142  $bulkHistory->setAddedLicenses($addedLicenses);
143  $this->assertEquals($addedLicenses, $bulkHistory->getAddedLicenses());
144  }
145 
153  {
154  $info = $this->getBulkHistoryInfo();
155  $bulkHistory = $info['obj'];
156  $removedLicenses = ['LicenseX', 'LicenseY'];
157  $bulkHistory->setRemovedLicenses($removedLicenses);
158  $this->assertEquals($removedLicenses, $bulkHistory->getRemovedLicenses());
159  }
160 }