FOSSology  4.5.1
Open Source License Compliance by Open Source Software
SearchResultTest.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 
25 class SearchResultTest extends TestCase
26 {
28 
34  public function testConstructor()
35  {
36  $hash = new Hash('sha1checksum', 'md5checksum', 'sha256checksum', 123123);
37  $upload = new Upload(2, 'root', 3, '', 'my.tar.gz', '01-01-2020', null,
38  $hash);
39  $searchResult = new SearchResult($upload->getArray(), '12',
40  'fileinupload.txt');
41  $this->assertInstanceOf(SearchResult::class, $searchResult);
42  }
43 
48  public function testDataFormat()
49  {
50  $hash = new Hash('sha1checksum', 'md5checksum', 'sha256checksum', 123123);
51  $upload = new Upload(2, 'root', 3, '', 'my.tar.gz', '01-01-2020', null,
52  $hash);
53  $expectedResult = [
54  'upload' => $upload->getArray(),
55  'uploadTreeId' => 12,
56  'filename' => 'fileinupload.txt'
57  ];
58 
59  $actualResult = new SearchResult($upload->getArray(), '12',
60  'fileinupload.txt');
61 
62  $this->assertEquals($expectedResult, $actualResult->getArray());
63  }
64 }
Hash model holding information about file like checksums and size.
Definition: Hash.php:18
Model to hold search results.
Model class to hold Upload info.
Definition: Upload.php:17