295 ->willReturn(
'translation');
300 ->getMockBuilder(ilTermsOfServiceDocument::class)
301 ->disableOriginalConstructor()
305 ->expects($this->never())
309 ->expects($this->never())
310 ->method(
'attachCriterion');
312 $criterionAssignment = $this
313 ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
314 ->disableOriginalConstructor()
315 ->onlyMethods([
'getCriterionId',
'getCriterionValue'])
316 ->addMethods([
'getId'])
324 ->method(
'getCriterionId')
325 ->willReturn(
'usr_global_role');
328 ->method(
'getCriterionValue')
331 $criterionTypeFactory = $this
332 ->getMockBuilder(ilTermsOfServiceCriterionTypeFactoryInterface::class)
335 $criterionType1 = $this
336 ->getMockBuilder(ilTermsOfServiceCriterionType::class)
340 ->method(
'getTypeIdent')
341 ->willReturn(
'dummy1');
345 ->willReturn($this->getMockBuilder(ilTermsOfServiceCriterionTypeGUI::class)->getMock());
347 $criterionType2 = $this
348 ->getMockBuilder(ilTermsOfServiceCriterionType::class)
352 ->method(
'getTypeIdent')
353 ->willReturn(
'dummy2');
355 $criterionTypeGui2 = $this->getMockBuilder(ilTermsOfServiceCriterionTypeGUI::class)->getMock();
358 ->method(
'getConfigByForm')
359 ->willReturn($criterionAssignment->getCriterionValue());
363 ->willReturn($criterionTypeGui2);
365 $criterionTypeFactory
366 ->expects($this->once())
367 ->method(
'getTypesByIdentMap')
373 $criterionTypeFactory
374 ->expects($this->exactly(2))
375 ->method(
'findByTypeIdent')
376 ->willReturnOnConsecutiveCalls(
381 $anotherCriterionAssignment = $this
382 ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
383 ->disableOriginalConstructor()
384 ->onlyMethods([
'getCriterionId',
'getCriterionValue'])
385 ->addMethods([
'getId'])
388 $anotherCriterionAssignment
392 $anotherCriterionAssignment
393 ->method(
'getCriterionId')
394 ->willReturn(
'usr_global_role');
396 $anotherCriterionAssignment
397 ->method(
'getCriterionValue')
401 ->expects($this->once())
403 ->willReturn([$anotherCriterionAssignment]);
406 ->getMockBuilder(ilObjUser::class)
407 ->disableOriginalConstructor()
408 ->onlyMethods([
'getId'])
415 $form = $this->getMockBuilder(ilTermsOfServiceCriterionFormGUI::class)
416 ->setConstructorArgs([
418 $criterionAssignment,
419 $criterionTypeFactory,
425 ->onlyMethods([
'checkInput'])
429 ->expects($this->exactly(2))
430 ->method(
'checkInput')
433 $form->setCheckInputCalled(
true);
437 'Failed asserting form cannot be saved selected criterion type was not found' 439 $this->assertTrue($form->hasTranslatedError());
440 $this->assertNotEmpty($form->getTranslatedError());
444 'Failed asserting form cannot be saved selected criterion type was already assigned to document' 446 $this->assertTrue($form->hasTranslatedError());
447 $this->assertNotEmpty($form->getTranslatedError());
setGlobalVariable(string $name, $value)
Class ilTermsOfServiceCriterionTypeNotFoundException.
Class ilTermsOfServiceCriterionConfig.