FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
LicenseMatchTest.php
1 <?php
2 /*
3  Copyright (C) 2014-2015, Siemens AG
4  Author: Johannes Najjar
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 namespace Fossology\Lib\Data;
21 
22 class LicenseMatchTest extends \PHPUnit\Framework\TestCase
23 {
25  private $licenseRef;
27  private $agentRef;
29  private $percent;
31  private $fileId;
33  private $licenseFileId;
35  private $id;
37  private $shortName;
39  private $fullName;
41  private $agentId;
43  private $agentName;
45  private $agentRevision;
47  private $licenseMatch;
48 
49  protected function setUp()
50  {
51  $this->id = 8;
52  $this->shortName = "testSN";
53  $this->fullName = "testFN";
54  $this->licenseRef = new LicenseRef($this->id, $this->shortName, $this->fullName);
55 
56  $this->agentId = 12;
57  $this->agentName = "Monk";
58  $this->agentRevision = "AgentRev";
59  $this->agentRef = new AgentRef($this->agentId, $this->agentName, $this->agentRevision);
60 
61  $this->percent = 40;
62  $this->fileId = 18;
63  $this->licenseFileId = 12;
64 
65  $this->licenseMatch = new LicenseMatch($this->fileId, $this->licenseRef, $this->agentRef, $this->licenseFileId, $this->percent);
66 
67  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
68  }
69 
70  protected function tearDown()
71  {
72  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
73  }
74 
75  public function testGetFileId()
76  {
77  assertThat($this->licenseMatch->getFileId(), is($this->fileId));
78  }
79 
80  public function testGetLicenseFileId()
81  {
82  assertThat($this->licenseMatch->getLicenseFileId(), is($this->licenseFileId));
83  }
84 
85  public function testGetLicenseRef()
86  {
87  assertThat($this->licenseMatch->getLicenseRef(), is($this->licenseRef));
88  }
89 
90  public function testGetAgentRef()
91  {
92  assertThat($this->licenseMatch->getAgentRef(), is($this->agentRef));
93  assertThat($this->licenseMatch->getAgentRef(), is(new AgentRef($this->agentId, $this->agentName, $this->agentRevision)));
94  }
95 
96  public function testGetPercent()
97  {
98  assertThat($this->licenseMatch->getPercentage(), is($this->percent));
99  }
100 
101  public function testGetLicenseId()
102  {
103  assertThat($this->licenseMatch->getLicenseId(), equalTo($this->id));
104  }
105 }