FOSSology  4.5.1
Open Source License Compliance by Open Source Software
UploadTest.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 
18 
19 use \PHPUnit\Framework\TestCase;
20 
21 
26 class UploadTest extends TestCase
27 {
28 
30 
36  public function testConstructor()
37  {
38  $hash = new Hash('sha1checksum', 'md5checksum', 'sha256checksum', 123123);
39  $upload = new Upload(2, 'root', 3, '', 'my.tar.gz', '01-01-2020', 3,
40  $hash);
41  $this->assertInstanceOf(Upload::class, $upload);
42  }
43 
48  public function testDataFormatV1()
49  {
50  $this->testDataFormat(ApiVersion::V1);
51  }
56  public function testDataFormatV2()
57  {
58  $this->testDataFormat(ApiVersion::V2);
59  }
65  private function testDataFormat($version)
66  {
67  $hash = new Hash('sha1checksum', 'md5checksum', 'sha256checksum', 123123);
68  if($version==ApiVersion::V1){
69  $expectedUpload = [
70  "folderid" => 2,
71  "foldername" => 'root',
72  "id" => 3,
73  "description" => '',
74  "uploadname" => 'my.tar.gz',
75  "uploaddate" => '01-01-2020',
76  "assignee" => 3,
77  "assigneeDate" => '01-01-2020',
78  "closingDate" => '01-01-2020',
79  "hash" => $hash->getArray()
80  ];
81  } else{
82  $expectedUpload = [
83  "folderId" => 2,
84  "folderName" => 'root',
85  "id" => 3,
86  "description" => '',
87  "uploadName" => 'my.tar.gz',
88  "uploadDate" => '01-01-2020',
89  "assignee" => 3,
90  "assigneeDate" => '01-01-2020',
91  "closingDate" => '01-01-2020',
92  "hash" => $hash->getArray()
93  ];
94  }
95 
96  $actualUpload = new Upload(2, 'root', 3, '', 'my.tar.gz', '01-01-2020', 3,
97  $hash);
98  $actualUpload->setAssigneeDate("01-01-2020");
99  $actualUpload->setClosingDate("01-01-2020");
100 
101  $this->assertEquals($expectedUpload, $actualUpload->getArray($version));
102  }
103 }
Hash model holding information about file like checksums and size.
Definition: Hash.php:18
Model class to hold Upload info.
Definition: Upload.php:17