302 ->expects($this->any())
304 ->willReturn(
'translation');
309 ->getMockBuilder(\ilTermsOfServiceDocument::class)
310 ->disableOriginalConstructor()
314 ->expects($this->never())
318 ->expects($this->never())
319 ->method(
'attachCriterion');
321 $criterionAssignment = $this
322 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
323 ->disableOriginalConstructor()
324 ->setMethods([
'getId',
'getCriterionId',
'getCriterionValue'])
328 ->expects($this->any())
333 ->expects($this->any())
334 ->method(
'getCriterionId')
335 ->willReturn(
'usr_global_role');
338 ->expects($this->any())
339 ->method(
'getCriterionValue')
342 $criterionTypeFactory = $this
343 ->getMockBuilder(\ilTermsOfServiceCriterionTypeFactoryInterface::class)
346 $criterionType1 = $this
347 ->getMockBuilder(\ilTermsOfServiceCriterionType::class)
351 ->expects($this->any())
352 ->method(
'getTypeIdent')
353 ->willReturn(
'dummy1');
356 ->expects($this->any())
358 ->willReturn($this->getMockBuilder(\ilTermsOfServiceCriterionTypeGUI::class)->getMock());
360 $criterionType2 = $this
361 ->getMockBuilder(\ilTermsOfServiceCriterionType::class)
365 ->expects($this->any())
366 ->method(
'getTypeIdent')
367 ->willReturn(
'dummy2');
369 $criterionTypeGui2 = $this->getMockBuilder(\ilTermsOfServiceCriterionTypeGUI::class)->getMock();
372 ->expects($this->any())
373 ->method(
'getConfigByForm')
374 ->willReturn($criterionAssignment->getCriterionValue());
377 ->expects($this->any())
379 ->willReturn($criterionTypeGui2);
381 $criterionTypeFactory
382 ->expects($this->
once())
383 ->method(
'getTypesByIdentMap')
385 $criterionType1, $criterionType2
388 $criterionTypeFactory
389 ->expects($this->exactly(2))
390 ->method(
'findByTypeIdent')
391 ->willReturnOnConsecutiveCalls(
396 $anotherCriterionAssignment = $this
397 ->getMockBuilder(\ilTermsOfServiceDocumentCriterionAssignment::class)
398 ->disableOriginalConstructor()
399 ->setMethods([
'getId',
'getCriterionId',
'getCriterionValue'])
402 $anotherCriterionAssignment
403 ->expects($this->any())
407 $anotherCriterionAssignment
408 ->expects($this->any())
409 ->method(
'getCriterionId')
410 ->willReturn(
'usr_global_role');
412 $anotherCriterionAssignment
413 ->expects($this->any())
414 ->method(
'getCriterionValue')
418 ->expects($this->
once())
420 ->willReturn([$anotherCriterionAssignment]);
423 ->getMockBuilder(\ilObjUser::class)
424 ->disableOriginalConstructor()
425 ->setMethods([
'getId'])
429 ->expects($this->any())
433 $form = $this->getMockBuilder(\ilTermsOfServiceCriterionFormGUI::class)
434 ->setConstructorArgs([
435 $document, $criterionAssignment, $criterionTypeFactory,
$user,
436 'action',
'save',
'cancel' 438 ->setMethods([
'checkInput'])
442 ->expects($this->exactly(2))
443 ->method(
'checkInput')
447 'criterion' => $criterionType1->getTypeIdent()
450 $form->setCheckInputCalled(
true);
454 'Failed asserting form cannot be saved selected criterion type was not found' 456 $this->assertTrue(
$form->hasTranslatedError());
457 $this->assertNotEmpty(
$form->getTranslatedError());
461 'Failed asserting form cannot be saved selected criterion type was already assigned to document' 463 $this->assertTrue(
$form->hasTranslatedError());
464 $this->assertNotEmpty(
$form->getTranslatedError());
setGlobalVariable(string $name, $value)
Class ilTermsOfServiceCriterionTypeNotFoundException.
Class ilTermsOfServiceCriterionConfig.
if(isset($_POST['submit'])) $form
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.