FOSSology  4.4.0
Open Source License Compliance by Open Source Software
LicenseMatchTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2015 Siemens AG
4  Author: Johannes Najjar
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Data;
9 
10 class LicenseMatchTest extends \PHPUnit\Framework\TestCase
11 {
13  private $licenseRef;
15  private $agentRef;
17  private $percent;
19  private $fileId;
21  private $licenseFileId;
23  private $id;
25  private $shortName;
27  private $fullName;
29  private $agentId;
31  private $agentName;
33  private $agentRevision;
35  private $licenseMatch;
36 
37  protected function setUp() : void
38  {
39  $this->id = 8;
40  $this->shortName = "testSN";
41  $this->spdxId = "testSN";
42  $this->fullName = "testFN";
43  $this->licenseRef = new LicenseRef($this->id, $this->shortName, $this->fullName, $this->spdxId);
44 
45  $this->agentId = 12;
46  $this->agentName = "Monk";
47  $this->agentRevision = "AgentRev";
48  $this->agentRef = new AgentRef($this->agentId, $this->agentName, $this->agentRevision);
49 
50  $this->percent = 40;
51  $this->fileId = 18;
52  $this->licenseFileId = 12;
53 
54  $this->licenseMatch = new LicenseMatch($this->fileId, $this->licenseRef, $this->agentRef, $this->licenseFileId, $this->percent);
55 
56  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
57  }
58 
59  protected function tearDown() : void
60  {
61  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
62  }
63 
64  public function testGetFileId()
65  {
66  assertThat($this->licenseMatch->getFileId(), is($this->fileId));
67  }
68 
69  public function testGetLicenseFileId()
70  {
71  assertThat($this->licenseMatch->getLicenseFileId(), is($this->licenseFileId));
72  }
73 
74  public function testGetLicenseRef()
75  {
76  assertThat($this->licenseMatch->getLicenseRef(), is($this->licenseRef));
77  }
78 
79  public function testGetAgentRef()
80  {
81  assertThat($this->licenseMatch->getAgentRef(), is($this->agentRef));
82  assertThat($this->licenseMatch->getAgentRef(), is(new AgentRef($this->agentId, $this->agentName, $this->agentRevision)));
83  }
84 
85  public function testGetPercent()
86  {
87  assertThat($this->licenseMatch->getPercentage(), is($this->percent));
88  }
89 
90  public function testGetLicenseId()
91  {
92  assertThat($this->licenseMatch->getLicenseId(), equalTo($this->id));
93  }
94 }