FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ClearingEventTest.php
1 <?php
2 /*
3 Copyright (C) 2014-2015, 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 
21 use Mockery as M;
22 
23 class ClearingEventTest extends \PHPUnit\Framework\TestCase
24 {
26  private $eventId = 12;
28  private $uploadTreeId = 5;
30  private $userId = 93;
32  private $groupId = 123;
34  private $eventType = ClearingEventTypes::USER;
36  private $clearingLicense;
38  private $licenseDecisionEvent;
40  private $timestamp;
41 
42  protected function setUp()
43  {
44  $this->timestamp = time();
45  $this->clearingLicense = M::mock(ClearingLicense::class);
46 
47  $this->licenseDecisionEvent = new ClearingEvent($this->eventId, $this->uploadTreeId, $this->timestamp, $this->userId, $this->groupId, $this->eventType, $this->clearingLicense);
48  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
49  }
50 
51  protected function tearDown()
52  {
53  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
54  }
55 
56  public function testGetEventId()
57  {
58  assertThat($this->licenseDecisionEvent->getEventId(), is($this->eventId));
59  }
60 
61  public function testGetEventType()
62  {
63  assertThat($this->licenseDecisionEvent->getEventType(), is($this->eventType));
64  }
65 
66  public function testGetTimeStamp()
67  {
68  assertThat($this->licenseDecisionEvent->getTimeStamp(), is($this->timestamp));
69  }
70 
71  public function testGetClearingLicense()
72  {
73  assertThat($this->licenseDecisionEvent->getClearingLicense(),
74  is($this->clearingLicense));
75  }
76 
77  public function testGetUploadTreeId()
78  {
79  assertThat($this->licenseDecisionEvent->getUploadTreeId(),
80  is($this->uploadTreeId));
81  }
82 
83  public function testGetLicenseId()
84  {
85  $licenseId = 1234;
86  $this->clearingLicense->shouldReceive('getLicenseId')
87  ->once()
88  ->withNoArgs()
89  ->andReturn($licenseId);
90 
91  assertThat($this->licenseDecisionEvent->getLicenseId(), is($licenseId));
92  }
93 
94  public function testGetLicenseShortName()
95  {
96  $licenseShortname = "<licenseShortname>";
97  $this->clearingLicense->shouldReceive('getShortName')
98  ->once()
99  ->withNoArgs()
100  ->andReturn($licenseShortname);
101 
102  assertThat($this->licenseDecisionEvent->getLicenseShortName(),
103  is($licenseShortname));
104  }
105 
106  public function testGetLicenseFullName()
107  {
108  $licenseFullname = "<licenseFullname>";
109  $this->clearingLicense->shouldReceive('getFullName')
110  ->once()
111  ->withNoArgs()
112  ->andReturn($licenseFullname);
113 
114  assertThat($this->licenseDecisionEvent->getLicenseFullName(),
115  is($licenseFullname));
116  }
117 
118  public function testGetUserId()
119  {
120  assertThat($this->licenseDecisionEvent->getUserId(), is($this->userId));
121  }
122 
123  public function testGetGroupId()
124  {
125  assertThat($this->licenseDecisionEvent->getGroupId(), is($this->groupId));
126  }
127 }