FOSSology  4.4.0
Open Source License Compliance by Open Source Software
AgentClearingEventTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2018 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Data\Clearing;
9 
12 use Mockery as M;
13 
14 class AgentClearingEventTest extends \PHPUnit\Framework\TestCase
15 {
17  private $licenseRef;
18 
20  private $agentRef;
21 
23  private $matchId = 1234;
24 
26  private $percentage = 95;
27 
29  private $agentClearingEvent;
30 
31  protected function setUp() : void
32  {
33  $this->licenseRef = M::mock(LicenseRef::class);
34  $this->agentRef = M::mock(AgentRef::class);
35 
36  $this->agentClearingEvent = new AgentClearingEvent($this->licenseRef, $this->agentRef, $this->matchId, $this->percentage);
37  }
38 
39  protected function tearDown() : void
40  {
41  M::close();
42  }
43 
44  public function testGetMatchId()
45  {
46  assertThat($this->agentClearingEvent->getMatchId(), is($this->matchId));
47  }
48 
49  public function testGetLicenseRef()
50  {
51  assertThat($this->agentClearingEvent->getLicenseRef(), is($this->licenseRef));
52  }
53 
54  public function testGetLicenseId()
55  {
56  $licenseId = 1234;
57  $this->licenseRef->shouldReceive('getId')
58  ->once()
59  ->withNoArgs()
60  ->andReturn($licenseId);
61 
62  assertThat($this->agentClearingEvent->getLicenseId(), is($licenseId));
63  }
64 
65  public function testGetLicenseShortName()
66  {
67  $licenseShortname = "<licenseShortname>";
68  $this->licenseRef->shouldReceive('getShortName')
69  ->once()
70  ->withNoArgs()
71  ->andReturn($licenseShortname);
72 
73  assertThat($this->agentClearingEvent->getLicenseShortName(),
74  is($licenseShortname));
75  }
76 
77  public function testGetLicenseFullName()
78  {
79  $licenseFullName = "<licenseFullName>";
80  $this->licenseRef->shouldReceive('getFullName')
81  ->once()
82  ->withNoArgs()
83  ->andReturn($licenseFullName);
84 
85  assertThat($this->agentClearingEvent->getLicenseFullName(),
86  is($licenseFullName));
87  }
88 
89  public function testGetEventType()
90  {
91  assertThat($this->agentClearingEvent->getEventType(),
92  is(ClearingResult::AGENT_DECISION_TYPE));
93  }
94 
95  public function testGetComment()
96  {
97  assertThat($this->agentClearingEvent->getComment(), is(""));
98  }
99 
100  public function testGetReportinfo()
101  {
102  assertThat($this->agentClearingEvent->getReportinfo(), is(""));
103  }
104 
105  public function testGetAcknowledgement()
106  {
107  assertThat($this->agentClearingEvent->getAcknowledgement(), is(""));
108  }
109 
110  public function testIsRemoved()
111  {
112  assertThat($this->agentClearingEvent->isRemoved(), is(false));
113  }
114 
115  public function testGetAgentRef()
116  {
117  assertThat($this->agentClearingEvent->getAgentRef(), is($this->agentRef));
118  }
119 
120  public function testGetAgentId()
121  {
122  $agentId = 1234;
123  $this->agentRef->shouldReceive('getAgentId')
124  ->once()
125  ->withNoArgs()
126  ->andReturn($agentId);
127 
128  assertThat($this->agentClearingEvent->getAgentId(), is($agentId));
129  }
130 
131  public function testGetAgentName()
132  {
133  $agentName = "<agentName>";
134  $this->agentRef->shouldReceive('getAgentName')
135  ->once()
136  ->withNoArgs()
137  ->andReturn($agentName);
138 
139  assertThat($this->agentClearingEvent->getAgentName(), is($agentName));
140  }
141 
142  public function testGetPercentage()
143  {
144  assertThat($this->agentClearingEvent->getPercentage(), is($this->percentage));
145  }
146 }