313 ->expects($this->any())
315 ->willReturn(
'translation');
320 ->getMockBuilder(ilTermsOfServiceDocument::class)
321 ->disableOriginalConstructor()
325 ->expects($this->never())
329 ->expects($this->never())
330 ->method(
'attachCriterion');
332 $criterionAssignment = $this
333 ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
334 ->disableOriginalConstructor()
335 ->onlyMethods([
'getCriterionId',
'getCriterionValue'])
336 ->addMethods([
'getId'])
340 ->expects($this->any())
345 ->expects($this->any())
346 ->method(
'getCriterionId')
347 ->willReturn(
'usr_global_role');
350 ->expects($this->any())
351 ->method(
'getCriterionValue')
354 $criterionTypeFactory = $this
355 ->getMockBuilder(ilTermsOfServiceCriterionTypeFactoryInterface::class)
358 $criterionType1 = $this
359 ->getMockBuilder(ilTermsOfServiceCriterionType::class)
363 ->expects($this->any())
364 ->method(
'getTypeIdent')
365 ->willReturn(
'dummy1');
368 ->expects($this->any())
370 ->willReturn($this->getMockBuilder(ilTermsOfServiceCriterionTypeGUI::class)->getMock());
372 $criterionType2 = $this
373 ->getMockBuilder(ilTermsOfServiceCriterionType::class)
377 ->expects($this->any())
378 ->method(
'getTypeIdent')
379 ->willReturn(
'dummy2');
381 $criterionTypeGui2 = $this->getMockBuilder(ilTermsOfServiceCriterionTypeGUI::class)->getMock();
384 ->expects($this->any())
385 ->method(
'getConfigByForm')
386 ->willReturn($criterionAssignment->getCriterionValue());
389 ->expects($this->any())
391 ->willReturn($criterionTypeGui2);
393 $criterionTypeFactory
394 ->expects($this->once())
395 ->method(
'getTypesByIdentMap')
401 $criterionTypeFactory
402 ->expects($this->exactly(2))
403 ->method(
'findByTypeIdent')
404 ->willReturnOnConsecutiveCalls(
409 $anotherCriterionAssignment = $this
410 ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
411 ->disableOriginalConstructor()
412 ->onlyMethods([
'getCriterionId',
'getCriterionValue'])
413 ->addMethods([
'getId'])
416 $anotherCriterionAssignment
417 ->expects($this->any())
421 $anotherCriterionAssignment
422 ->expects($this->any())
423 ->method(
'getCriterionId')
424 ->willReturn(
'usr_global_role');
426 $anotherCriterionAssignment
427 ->expects($this->any())
428 ->method(
'getCriterionValue')
432 ->expects($this->once())
434 ->willReturn([$anotherCriterionAssignment]);
437 ->getMockBuilder(ilObjUser::class)
438 ->disableOriginalConstructor()
439 ->onlyMethods([
'getId'])
443 ->expects($this->any())
447 $form = $this->getMockBuilder(ilTermsOfServiceCriterionFormGUI::class)
448 ->setConstructorArgs([
450 $criterionAssignment,
451 $criterionTypeFactory,
457 ->onlyMethods([
'checkInput'])
461 ->expects($this->exactly(2))
462 ->method(
'checkInput')
466 'criterion' => $criterionType1->getTypeIdent()
469 $form->setCheckInputCalled(
true);
473 'Failed asserting form cannot be saved selected criterion type was not found' 475 $this->assertTrue($form->hasTranslatedError());
476 $this->assertNotEmpty($form->getTranslatedError());
480 'Failed asserting form cannot be saved selected criterion type was already assigned to document' 482 $this->assertTrue($form->hasTranslatedError());
483 $this->assertNotEmpty($form->getTranslatedError());
setGlobalVariable(string $name, $value)
Class ilTermsOfServiceCriterionTypeNotFoundException.
Class ilTermsOfServiceCriterionConfig.