FOSSology  4.4.0
Open Source License Compliance by Open Source Software
ClearingEventTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2014-2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\Data\Clearing;
9 
10 use Mockery as M;
11 
12 class ClearingEventTest extends \PHPUnit\Framework\TestCase
13 {
15  private $eventId = 12;
17  private $uploadTreeId = 5;
19  private $userId = 93;
21  private $groupId = 123;
23  private $eventType = ClearingEventTypes::USER;
25  private $clearingLicense;
27  private $licenseDecisionEvent;
29  private $timestamp;
30 
31  protected function setUp() : void
32  {
33  $this->timestamp = time();
34  $this->clearingLicense = M::mock(ClearingLicense::class);
35 
36  $this->licenseDecisionEvent = new ClearingEvent($this->eventId, $this->uploadTreeId, $this->timestamp, $this->userId, $this->groupId, $this->eventType, $this->clearingLicense);
37  $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
38  }
39 
40  protected function tearDown() : void
41  {
42  $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
43  }
44 
45  public function testGetEventId()
46  {
47  assertThat($this->licenseDecisionEvent->getEventId(), is($this->eventId));
48  }
49 
50  public function testGetEventType()
51  {
52  assertThat($this->licenseDecisionEvent->getEventType(), is($this->eventType));
53  }
54 
55  public function testGetTimeStamp()
56  {
57  assertThat($this->licenseDecisionEvent->getTimeStamp(), is($this->timestamp));
58  }
59 
60  public function testGetClearingLicense()
61  {
62  assertThat($this->licenseDecisionEvent->getClearingLicense(),
63  is($this->clearingLicense));
64  }
65 
66  public function testGetUploadTreeId()
67  {
68  assertThat($this->licenseDecisionEvent->getUploadTreeId(),
69  is($this->uploadTreeId));
70  }
71 
72  public function testGetLicenseId()
73  {
74  $licenseId = 1234;
75  $this->clearingLicense->shouldReceive('getLicenseId')
76  ->once()
77  ->withNoArgs()
78  ->andReturn($licenseId);
79 
80  assertThat($this->licenseDecisionEvent->getLicenseId(), is($licenseId));
81  }
82 
83  public function testGetLicenseShortName()
84  {
85  $licenseShortname = "<licenseShortname>";
86  $this->clearingLicense->shouldReceive('getShortName')
87  ->once()
88  ->withNoArgs()
89  ->andReturn($licenseShortname);
90 
91  assertThat($this->licenseDecisionEvent->getLicenseShortName(),
92  is($licenseShortname));
93  }
94 
95  public function testGetLicenseFullName()
96  {
97  $licenseFullname = "<licenseFullname>";
98  $this->clearingLicense->shouldReceive('getFullName')
99  ->once()
100  ->withNoArgs()
101  ->andReturn($licenseFullname);
102 
103  assertThat($this->licenseDecisionEvent->getLicenseFullName(),
104  is($licenseFullname));
105  }
106 
107  public function testGetUserId()
108  {
109  assertThat($this->licenseDecisionEvent->getUserId(), is($this->userId));
110  }
111 
112  public function testGetGroupId()
113  {
114  assertThat($this->licenseDecisionEvent->getGroupId(), is($this->groupId));
115  }
116 }