FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
AgentClearingEventTest.php
1 <?php
2 /*
3 Copyright (C) 2014-2018, Siemens AG
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 version 2 as published by the Free Software Foundation.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
20 
23 use Mockery as M;
24 
25 class AgentClearingEventTest extends \PHPUnit\Framework\TestCase
26 {
28  private $licenseRef;
29 
31  private $agentRef;
32 
34  private $matchId = 1234;
35 
37  private $percentage = 95;
38 
40  private $agentClearingEvent;
41 
42  protected function setUp()
43  {
44  $this->licenseRef = M::mock(LicenseRef::class);
45  $this->agentRef = M::mock(AgentRef::class);
46 
47  $this->agentClearingEvent = new AgentClearingEvent($this->licenseRef, $this->agentRef, $this->matchId, $this->percentage);
48  }
49 
50  protected function tearDown()
51  {
52  M::close();
53  }
54 
55  public function testGetMatchId()
56  {
57  assertThat($this->agentClearingEvent->getMatchId(), is($this->matchId));
58  }
59 
60  public function testGetLicenseRef()
61  {
62  assertThat($this->agentClearingEvent->getLicenseRef(), is($this->licenseRef));
63  }
64 
65  public function testGetLicenseId()
66  {
67  $licenseId = 1234;
68  $this->licenseRef->shouldReceive('getId')
69  ->once()
70  ->withNoArgs()
71  ->andReturn($licenseId);
72 
73  assertThat($this->agentClearingEvent->getLicenseId(), is($licenseId));
74  }
75 
76  public function testGetLicenseShortName()
77  {
78  $licenseShortname = "<licenseShortname>";
79  $this->licenseRef->shouldReceive('getShortName')
80  ->once()
81  ->withNoArgs()
82  ->andReturn($licenseShortname);
83 
84  assertThat($this->agentClearingEvent->getLicenseShortName(),
85  is($licenseShortname));
86  }
87 
88  public function testGetLicenseFullName()
89  {
90  $licenseFullName = "<licenseFullName>";
91  $this->licenseRef->shouldReceive('getFullName')
92  ->once()
93  ->withNoArgs()
94  ->andReturn($licenseFullName);
95 
96  assertThat($this->agentClearingEvent->getLicenseFullName(),
97  is($licenseFullName));
98  }
99 
100  public function testGetEventType()
101  {
102  assertThat($this->agentClearingEvent->getEventType(),
103  is(ClearingResult::AGENT_DECISION_TYPE));
104  }
105 
106  public function testGetComment()
107  {
108  assertThat($this->agentClearingEvent->getComment(), is(""));
109  }
110 
111  public function testGetReportinfo()
112  {
113  assertThat($this->agentClearingEvent->getReportinfo(), is(""));
114  }
115 
116  public function testGetAcknowledgement()
117  {
118  assertThat($this->agentClearingEvent->getAcknowledgement(), is(""));
119  }
120 
121  public function testIsRemoved()
122  {
123  assertThat($this->agentClearingEvent->isRemoved(), is(false));
124  }
125 
126  public function testGetAgentRef()
127  {
128  assertThat($this->agentClearingEvent->getAgentRef(), is($this->agentRef));
129  }
130 
131  public function testGetAgentId()
132  {
133  $agentId = 1234;
134  $this->agentRef->shouldReceive('getAgentId')
135  ->once()
136  ->withNoArgs()
137  ->andReturn($agentId);
138 
139  assertThat($this->agentClearingEvent->getAgentId(), is($agentId));
140  }
141 
142  public function testGetAgentName()
143  {
144  $agentName = "<agentName>";
145  $this->agentRef->shouldReceive('getAgentName')
146  ->once()
147  ->withNoArgs()
148  ->andReturn($agentName);
149 
150  assertThat($this->agentClearingEvent->getAgentName(), is($agentName));
151  }
152 
153  public function testGetPercentage()
154  {
155  assertThat($this->agentClearingEvent->getPercentage(), is($this->percentage));
156  }
157 }