FOSSology  4.5.1
Open Source License Compliance by Open Source Software
FileTest.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 
23 class FileTest extends \PHPUnit\Framework\TestCase
24 {
26 
32  public function testConstructor()
33  {
34  $hash = new Hash();
35  $file = new File($hash);
36 
37  $this->assertInstanceOf(File::class, $file);
38  }
39 
44  public function testDataFormat()
45  {
46  $expectedArray = [
47  "hash" => [
48  "sha1" => "sha1checksum",
49  "md5" => "md5checksum",
50  "sha256" => "sha256checksum",
51  "size" => 123
52  ],
53  "findings"=> [
54  "scanner" => [
55  "License1"
56  ],
57  "conclusion" => [
58  "License2"
59  ],
60  "copyright" => []
61  ],
62  "uploads" => []
63  ];
64 
65  $hash = new Hash('sha1checksum', 'md5checksum', 'sha256checksum', 123);
66  $findings = new Findings("License1", "License2", []);
67  $object = new File($hash);
68  $object->setFindings($findings);
69  $object->setUploads([]);
70 
71  $this->assertEquals($expectedArray, $object->getArray());
72  }
73 }
File model holding information about a single file.
Definition: File.php:19
Model holding information about license findings and conclusions.
Definition: Findings.php:18
Hash model holding information about file like checksums and size.
Definition: Hash.php:18