15 $criterionAssignment1 = $this
16 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
17 ->disableOriginalConstructor()
18 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId',
'store',
'delete'])
22 ->expects($this->any())
27 ->expects($this->any())
28 ->method(
'getCriterionId')
29 ->willReturn(
'usr_global_role');
32 ->expects($this->any())
33 ->method(
'getCriterionValue')
36 $criterionAssignment2 = $this
37 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
38 ->disableOriginalConstructor()
39 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId',
'store',
'delete'])
43 ->expects($this->any())
48 ->expects($this->any())
49 ->method(
'getCriterionId')
50 ->willReturn(
'usr_language');
53 ->expects($this->any())
54 ->method(
'getCriterionValue')
57 $criterionAssignment3 = $this
58 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
59 ->disableOriginalConstructor()
60 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId',
'store',
'delete'])
64 ->expects($this->any())
69 ->expects($this->any())
70 ->method(
'getCriterionId')
71 ->willReturn(
'usr_global_role');
74 ->expects($this->any())
75 ->method(
'getCriterionValue')
79 [$criterionAssignment1, $criterionAssignment2, $criterionAssignment3]
94 $documentConnector = $this->getMockBuilder(\arConnector::class)->getMock();
95 $criterionConnector = $this->getMockBuilder(\arConnector::class)->getMock();
98 ->expects($this->
once())
100 ->willReturnCallback(
function () use ($criterionAssignment1, $criterionAssignment2, $criterionAssignment3) {
102 'id' => $criterionAssignment1->getId(),
107 'id' => $criterionAssignment2->getId(),
112 'id' => $criterionAssignment3->getId(),
122 $document = new \ilTermsOfServiceDocument();
124 $document->buildFromArray([
126 'title' =>
'phpunit',
129 $this->assertCount(3, $document->criteria());
143 $documentConnector = $this->getMockBuilder(\arConnector::class)->getMock();
144 $criterionConnector = $this->getMockBuilder(\arConnector::class)->getMock();
147 ->expects($this->
once())
149 ->willReturnCallback(
function () {
153 $object->title =
'phpunit';
154 $object->creation_ts = time();
155 $object->modification_ts = time();
156 $object->owner_usr_id = 6;
157 $object->last_modified_usr_id = 6;
158 $object->sorting = 10;
159 $object->text =
'HelloWorld';
165 ->expects($this->
once())
167 ->willReturnCallback(
function () use ($criterionAssignment1, $criterionAssignment2, $criterionAssignment3) {
169 'id' => $criterionAssignment1->getId(),
174 'id' => $criterionAssignment2->getId(),
179 'id' => $criterionAssignment3->getId(),
189 $document = new \ilTermsOfServiceDocument(4711);
191 $this->assertCount(3, $document->criteria());
205 $document = new \ilTermsOfServiceDocument();
206 $document->attachCriterion($criterionAssignment1);
207 $document->attachCriterion($criterionAssignment2);
208 $document->attachCriterion($criterionAssignment3);
210 $this->assertCount(3, $document->criteria());
224 $document = new \ilTermsOfServiceDocument();
225 $document->attachCriterion($criterionAssignment1);
226 $document->attachCriterion($criterionAssignment2);
227 $document->attachCriterion($criterionAssignment3);
229 $this->assertCount(3, $document->criteria());
231 $document->detachCriterion($criterionAssignment2);
233 $this->assertCount(2, $document->criteria());
247 $documentConnector = $this->getMockBuilder(\arConnector::class)->getMock();
249 $document = new \ilTermsOfServiceDocument();
252 ->expects($this->exactly(2))
253 ->method(
'affectedRows')
254 ->willReturnOnConsecutiveCalls(0, 1);
257 ->expects($this->
once())
262 ->expects($this->
once())
267 $document->attachCriterion($criterionAssignment1);
268 $document->attachCriterion($criterionAssignment2);
269 $document->attachCriterion($criterionAssignment3);
271 $criterionAssignment1
272 ->expects($this->exactly(2))
275 $criterionAssignment1
276 ->expects($this->
once())
279 $criterionAssignment2
280 ->expects($this->
once())
283 $criterionAssignment2
284 ->expects($this->
once())
287 $criterionAssignment3
288 ->expects($this->exactly(2))
291 $criterionAssignment3
292 ->expects($this->
once())
295 $this->assertCount(3, $document->criteria());
299 $document->detachCriterion($criterionAssignment2);
303 $this->assertCount(2, $document->criteria());
305 $document->detachCriterion($criterionAssignment1);
306 $document->detachCriterion($criterionAssignment3);
308 $this->assertCount(0, $document->criteria());
318 $this->
assertException(\ilTermsOfServiceDuplicateCriterionAssignmentException::class);
320 $criterionAssignment1 = $this
321 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
322 ->disableOriginalConstructor()
323 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId'])
326 $criterionAssignment1
327 ->expects($this->any())
331 $criterionAssignment1
332 ->expects($this->any())
333 ->method(
'getCriterionId')
334 ->willReturn(
'usr_global_role');
336 $criterionAssignment1
337 ->expects($this->any())
338 ->method(
'getCriterionValue')
341 $criterionAssignment2 = $this
342 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
343 ->disableOriginalConstructor()
344 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId'])
347 $criterionAssignment2
348 ->expects($this->any())
352 $criterionAssignment2
353 ->expects($this->any())
354 ->method(
'getCriterionId')
355 ->willReturn(
'usr_global_role');
357 $criterionAssignment2
358 ->expects($this->any())
359 ->method(
'getCriterionValue')
362 $document = new \ilTermsOfServiceDocument();
364 $document->attachCriterion($criterionAssignment1);
365 $document->attachCriterion($criterionAssignment2);
373 $this->
assertException(\ilTermsOfServiceDuplicateCriterionAssignmentException::class);
375 $criterionAssignment1 = $this
376 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
377 ->disableOriginalConstructor()
378 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId'])
381 $criterionAssignment1
382 ->expects($this->any())
386 $criterionAssignment1
387 ->expects($this->any())
388 ->method(
'getCriterionId')
389 ->willReturn(
'usr_global_role');
391 $criterionAssignment1
392 ->expects($this->any())
393 ->method(
'getCriterionValue')
396 $criterionAssignment2 = $this
397 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
398 ->disableOriginalConstructor()
399 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId'])
402 $criterionAssignment2
403 ->expects($this->any())
407 $criterionAssignment2
408 ->expects($this->any())
409 ->method(
'getCriterionId')
410 ->willReturn(
'usr_global_role');
412 $criterionAssignment2
413 ->expects($this->any())
414 ->method(
'getCriterionValue')
417 $document = new \ilTermsOfServiceDocument();
419 $document->attachCriterion($criterionAssignment1);
420 $document->attachCriterion($criterionAssignment2);
430 $criterionAssignment1 = $this
431 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
432 ->disableOriginalConstructor()
433 ->setMethods([
'getId',
'getCriterionValue',
'getCriterionId'])
436 $criterionAssignment1
437 ->expects($this->any())
441 $criterionAssignment1
442 ->expects($this->any())
443 ->method(
'getCriterionId')
444 ->willReturn(
'usr_global_role');
446 $criterionAssignment1
447 ->expects($this->any())
448 ->method(
'getCriterionValue')
451 $document = new \ilTermsOfServiceDocument();
453 $document->detachCriterion($criterionAssignment1);
testDocumentModelCanCreatedByIdWithAttachedCriteriaBeingRead(\ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3)
criteriaAssignmentProvider
static register(ActiveRecord $ar, arConnector $connector)
assertException(string $exceptionClass)
testExceptionIsRaisedWhenAttachingDuplicateCriteria()
Class ilTermsOfServiceCriterionBaseTest.
Class ilTermsOfServiceDocumentTest.
testDocumentModelCanBeBuiltFromArrayWithAttachedCriteriaBeingRead(\ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3)
criteriaAssignmentProvider
criteriaAssignmentProvider()
testCriteriaCanBeDetachedFromDocument(\ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3)
criteriaAssignmentProvider
getCriterionConfig($value=null)
Class ilTermsOfServiceDocumentCriterionAssignment.
Class ilTermsOfServiceDocument.
testCriteriaCanBeAttachedToDocument(\ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3)
criteriaAssignmentProvider
testCriteriaCanBeAttachedToAndDetachedFromDocumentPersistently(\ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, \ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3)
criteriaAssignmentProvider
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
testExceptionIsRaisedWhenRemovingUnknownCriterion()
testExceptionIsRaisedWhenAttachingDuplicateCriteriaEvenWithDifferentIds()