310 ->expects($this->any())
312 ->willReturn(
'translation');
317 ->getMockBuilder(ilTermsOfServiceDocument::class)
318 ->disableOriginalConstructor()
322 ->expects($this->never())
326 ->expects($this->never())
327 ->method(
'attachCriterion');
329 $criterionAssignment = $this
330 ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
331 ->disableOriginalConstructor()
332 ->setMethods([
'getId',
'getCriterionId',
'getCriterionValue'])
336 ->expects($this->any())
341 ->expects($this->any())
342 ->method(
'getCriterionId')
343 ->willReturn(
'usr_global_role');
346 ->expects($this->any())
347 ->method(
'getCriterionValue')
350 $criterionTypeFactory = $this
351 ->getMockBuilder(ilTermsOfServiceCriterionTypeFactoryInterface::class)
354 $criterionType1 = $this
355 ->getMockBuilder(ilTermsOfServiceCriterionType::class)
359 ->expects($this->any())
360 ->method(
'getTypeIdent')
361 ->willReturn(
'dummy1');
364 ->expects($this->any())
366 ->willReturn($this->getMockBuilder(ilTermsOfServiceCriterionTypeGUI::class)->getMock());
368 $criterionType2 = $this
369 ->getMockBuilder(ilTermsOfServiceCriterionType::class)
373 ->expects($this->any())
374 ->method(
'getTypeIdent')
375 ->willReturn(
'dummy2');
377 $criterionTypeGui2 = $this->getMockBuilder(ilTermsOfServiceCriterionTypeGUI::class)->getMock();
380 ->expects($this->any())
381 ->method(
'getConfigByForm')
382 ->willReturn($criterionAssignment->getCriterionValue());
385 ->expects($this->any())
387 ->willReturn($criterionTypeGui2);
389 $criterionTypeFactory
390 ->expects($this->once())
391 ->method(
'getTypesByIdentMap')
397 $criterionTypeFactory
398 ->expects($this->exactly(2))
399 ->method(
'findByTypeIdent')
400 ->willReturnOnConsecutiveCalls(
405 $anotherCriterionAssignment = $this
406 ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
407 ->disableOriginalConstructor()
408 ->setMethods([
'getId',
'getCriterionId',
'getCriterionValue'])
411 $anotherCriterionAssignment
412 ->expects($this->any())
416 $anotherCriterionAssignment
417 ->expects($this->any())
418 ->method(
'getCriterionId')
419 ->willReturn(
'usr_global_role');
421 $anotherCriterionAssignment
422 ->expects($this->any())
423 ->method(
'getCriterionValue')
427 ->expects($this->once())
429 ->willReturn([$anotherCriterionAssignment]);
432 ->getMockBuilder(ilObjUser::class)
433 ->disableOriginalConstructor()
434 ->setMethods([
'getId'])
438 ->expects($this->any())
442 $form = $this->getMockBuilder(ilTermsOfServiceCriterionFormGUI::class)
443 ->setConstructorArgs([
445 $criterionAssignment,
446 $criterionTypeFactory,
452 ->setMethods([
'checkInput'])
456 ->expects($this->exactly(2))
457 ->method(
'checkInput')
461 'criterion' => $criterionType1->getTypeIdent()
464 $form->setCheckInputCalled(
true);
468 'Failed asserting form cannot be saved selected criterion type was not found' 470 $this->assertTrue($form->hasTranslatedError());
471 $this->assertNotEmpty($form->getTranslatedError());
475 'Failed asserting form cannot be saved selected criterion type was already assigned to document' 477 $this->assertTrue($form->hasTranslatedError());
478 $this->assertNotEmpty($form->getTranslatedError());
setGlobalVariable(string $name, $value)
Class ilTermsOfServiceCriterionTypeNotFoundException.
Class ilTermsOfServiceCriterionConfig.