FOSSology  4.4.0
Open Source License Compliance by Open Source Software
UploadSummaryTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2020 Siemens AG
4  Author: Gaurav Mishra <mishra.gaurav@siemens.com>
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
14 
17 
22 class UploadSummaryTest extends \PHPUnit\Framework\TestCase
23 {
28  public function testDataFormat()
29  {
30  $expected = [
31  "id" => 5,
32  "uploadName" => 'test.tar.gz',
33  "assignee" => 3,
34  "mainLicense" => 'MIT',
35  "uniqueLicenses" => 5,
36  "totalLicenses" => 25,
37  "uniqueConcludedLicenses" => 1,
38  "totalConcludedLicenses" => 25,
39  "filesToBeCleared" => 0,
40  "filesCleared" => 25,
41  "clearingStatus" => "Closed",
42  "copyrightCount" => 10,
43  "fileCount" => 25,
44  "noScannerLicenseFoundCount" => 0,
45  "scannerUniqueLicenseCount" => 0,
46  'concludedNoLicenseFoundCount' => 0
47  ];
48 
49  $actual = new UploadSummary();
50  $actual->setUploadId(5);
51  $actual->setUploadName('test.tar.gz');
52  $actual->setAssignee(3);
53  $actual->setMainLicense('MIT');
54  $actual->setUniqueLicenses(5);
55  $actual->setTotalLicenses(25);
56  $actual->setUniqueConcludedLicenses(1);
57  $actual->setTotalConcludedLicenses(25);
58  $actual->setFilesToBeCleared(0);
59  $actual->setFilesCleared(25);
60  $actual->setClearingStatus(UploadStatus::CLOSED);
61  $actual->setCopyrightCount(10);
62  $actual->setFileCount(25);
63  $actual->setNoScannerLicenseFoundCount(0);
64  $actual->setScannerUniqueLicenseCount(0);
65  $actual->setConcludedNoLicenseFoundCount(0);
66 
67  $this->assertEquals($expected, $actual->getArray());
68  }
69 
77  public function testStatusToString()
78  {
79  $expectedOpen = "Open";
80  $expectedProgress = "InProgress";
81  $expectedClosed = "Closed";
82  $expectedRejected = "Rejected";
83  $expectedDefault = "NA";
84 
85  $this->assertEquals($expectedOpen,
86  UploadSummary::statusToString(UploadStatus::OPEN));
87  $this->assertEquals($expectedProgress,
88  UploadSummary::statusToString(UploadStatus::IN_PROGRESS));
89  $this->assertEquals($expectedClosed,
90  UploadSummary::statusToString(UploadStatus::CLOSED));
91  $this->assertEquals($expectedRejected,
92  UploadSummary::statusToString(UploadStatus::REJECTED));
93  $this->assertEquals($expectedDefault, UploadSummary::statusToString(null));
94  $this->assertEquals($expectedDefault,
96  }
97 }
Model class to hold Upload info.
Test cases for UploadSummary model.