FOSSology  4.4.0
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 
24 class UploadTest extends \PHPUnit\Framework\TestCase
25 {
26 
31  public function testDataFormatV1()
32  {
33  $this->testDataFormat(ApiVersion::V1);
34  }
39  public function testDataFormatV2()
40  {
41  $this->testDataFormat(ApiVersion::V2);
42  }
48  private function testDataFormat($version)
49  {
50  $hash = new Hash('sha1checksum', 'md5checksum', 'sha256checksum', 123123);
51  if($version==ApiVersion::V1){
52  $expectedUpload = [
53  "folderid" => 2,
54  "foldername" => 'root',
55  "id" => 3,
56  "description" => '',
57  "uploadname" => 'my.tar.gz',
58  "uploaddate" => '01-01-2020',
59  "assignee" => 3,
60  "assigneeDate" => '01-01-2020',
61  "closingDate" => '01-01-2020',
62  "hash" => $hash->getArray()
63  ];
64  } else{
65  $expectedUpload = [
66  "folderId" => 2,
67  "folderName" => 'root',
68  "id" => 3,
69  "description" => '',
70  "uploadName" => 'my.tar.gz',
71  "uploadDate" => '01-01-2020',
72  "assignee" => 3,
73  "assigneeDate" => '01-01-2020',
74  "closingDate" => '01-01-2020',
75  "hash" => $hash->getArray()
76  ];
77  }
78 
79  $actualUpload = new Upload(2, 'root', 3, '', 'my.tar.gz', '01-01-2020', 3,
80  $hash);
81  $actualUpload->setAssigneeDate("01-01-2020");
82  $actualUpload->setClosingDate("01-01-2020");
83 
84  $this->assertEquals($expectedUpload, $actualUpload->getArray($version));
85  }
86 }
Hash model holding information about file like checksums and size.
Definition: Hash.php:18
Model class to hold Upload info.
Definition: Upload.php:17