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