9 namespace Fossology\Lib\Data;
20 private $sameUpload =
true;
22 private $sameFolder =
true;
24 private $clearingEvent;
28 private $uploadTreeId;
42 private $acknowledgement;
49 private $clearingDecisionBuilder;
51 protected function setUp() :
void
53 $this->sameUpload =
true;
54 $this->sameFolder =
true;
55 $this->clearingEvent = M::mock(ClearingEvent::class);
56 $this->clearingId = 8;
57 $this->uploadTreeId = 9;
59 $this->userName =
"tester";
61 $this->type = DecisionTypes::TO_BE_DISCUSSED;
62 $this->comment =
"Test comment";
63 $this->reportinfo =
"Test reportinfo";
64 $this->acknowledgement =
"Test acknowledgement";
65 $this->scope = DecisionScopes::ITEM;
66 $this->timeStamp = mktime(11, 14, 15, 7, 28, 2012);
69 $this->assertCountBefore = \Hamcrest\MatcherAssert::getCount();
72 protected function tearDown() :
void
74 $this->addToAssertionCount(\Hamcrest\MatcherAssert::getCount()-$this->assertCountBefore);
78 public function testSameFolder()
80 $clearingDec =$this->clearingDecisionBuilder
81 ->setSameFolder($this->sameFolder)
83 assertThat($clearingDec->getSameFolder(), is($this->sameFolder));
86 public function testClearingLicenses()
88 $clearingDec = $this->clearingDecisionBuilder
89 ->setClearingEvents(array($this->clearingEvent))
91 assertThat($clearingDec->getClearingEvents(), is(arrayContaining($this->clearingEvent)));
94 public function testPositiveLicenses()
96 $addedLic = M::mock(LicenseRef::class);
98 $addedClearingLic = M::mock(ClearingLicense::class);
99 $addedClearingLic->shouldReceive(
'isRemoved')->withNoArgs()->andReturn(
false);
100 $addedClearingLic->shouldReceive(
'getLicenseRef')->withNoArgs()->andReturn($addedLic);
102 $removedClearingLic = M::mock(ClearingLicense::class);
103 $removedClearingLic->shouldReceive(
'isRemoved')->andReturn(
true);
105 $removedClearingEvent = M::mock(ClearingEvent::class);
107 $this->clearingEvent->shouldReceive(
'getClearingLicense')->andReturn($addedClearingLic);
108 $removedClearingEvent->shouldReceive(
'getClearingLicense')->andReturn($removedClearingLic);
110 $clearingDec = $this->clearingDecisionBuilder
111 ->setClearingEvents(array($this->clearingEvent, $removedClearingEvent))
113 assertThat($clearingDec->getPositiveLicenses(), is(arrayContaining($addedLic)));
116 public function testClearingId()
118 $clearingDec = $this->clearingDecisionBuilder
119 ->setClearingId($this->clearingId)
121 assertThat($clearingDec->getClearingId(), is($this->clearingId));
124 public function testUploadTreeId()
126 $clearingDec = $this->clearingDecisionBuilder
127 ->setUploadTreeId($this->uploadTreeId)
129 assertThat($clearingDec->getUploadTreeId(), is($this->uploadTreeId));
132 public function testPfileId()
134 $clearingDec = $this->clearingDecisionBuilder
135 ->setPfileId($this->pfileId)
137 assertThat($clearingDec->getPfileId(), is($this->pfileId));
140 public function testUserName()
142 $clearingDec = $this->clearingDecisionBuilder
143 ->setUserName($this->userName)
145 assertThat($clearingDec->getUserName(), is($this->userName));
148 public function testUserId()
150 $clearingDec = $this->clearingDecisionBuilder
151 ->setUserId($this->userId)
153 assertThat($clearingDec->getUserId(), is($this->userId));
156 public function testType()
158 $clearingDec = $this->clearingDecisionBuilder
159 ->setType($this->type)
161 assertThat($clearingDec->getType(), is($this->type));
164 public function testDateAdded()
166 $clearingDec = $this->clearingDecisionBuilder
167 ->setTimeStamp($this->timeStamp)
169 assertThat($clearingDec->getTimeStamp(), is($this->timeStamp));