ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceDocumentCriterionAssignmentConstraintTest Class Reference

Class ilTermsOfServiceDocumentCriterionAssignmentConstraintTest. More...

+ Inheritance diagram for ilTermsOfServiceDocumentCriterionAssignmentConstraintTest:
+ Collaboration diagram for ilTermsOfServiceDocumentCriterionAssignmentConstraintTest:

Public Member Functions

 criteriaAssignmentProvider ()
 
 testConstraintAcceptanceWorksAsExpected (ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment4)
 criteriaAssignmentProvider More...
 
 testConstraintCheckWorksAsExpected (ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment4)
 criteriaAssignmentProvider More...
 
 testConstraintProblemDetectionWorksAsExpected (ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment4)
 criteriaAssignmentProvider More...
 
 testConstraintRestrictionWorksAsExpected (ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment4)
 criteriaAssignmentProvider More...
 
 testConstraintProblemBuilderWorksAsExpected (ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment4)
 criteriaAssignmentProvider More...
 
 testConstraintExposesCorrectErrorMessagesAfterMultiAccept (ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment4)
 criteriaAssignmentProvider More...
 
 testCriterionWithSameNatureIsNotAcceptedWhenAlreadyAssigned (ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment1, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment2, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment3, ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment4)
 criteriaAssignmentProvider More...
 

Protected Member Functions

 getCriterionTypeFactoryMock ()
 
 getCriterionTypeMock (string $typeIdent)
 
 getTypeMockForConstraint ()
 
- Protected Member Functions inherited from ilTermsOfServiceCriterionBaseTest
 getRbacReviewMock ()
 
 getObjectDataCacheMock ()
 
 getRadioGroupMock ()
 
 getFormMock ()
 
 getUserMock ()
 
- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 

Additional Inherited Members

- Protected Attributes inherited from ilTermsOfServiceBaseTest
 $dic
 

Detailed Description

Member Function Documentation

◆ criteriaAssignmentProvider()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::criteriaAssignmentProvider ( )
Returns
array
Exceptions
ReflectionException

Definition at line 79 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References ilTermsOfServiceBaseTest\getCriterionConfig().

79  : array
80  {
81  $criterionAssignment1 = $this
82  ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
83  ->disableOriginalConstructor()
84  ->setMethods(['getId', 'getCriterionValue', 'getCriterionId'])
85  ->getMock();
86 
87  $criterionAssignment1
88  ->expects($this->any())
89  ->method('getId')
90  ->willReturn(1);
91 
92  $criterionAssignment1
93  ->expects($this->any())
94  ->method('getCriterionId')
95  ->willReturn('usr_global_role');
96 
97  $criterionAssignment1
98  ->expects($this->any())
99  ->method('getCriterionValue')
100  ->willReturn($this->getCriterionConfig(['role_id' => 4]));
101 
102  $criterionAssignment2 = $this
103  ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
104  ->disableOriginalConstructor()
105  ->setMethods(['getId', 'getCriterionValue', 'getCriterionId'])
106  ->getMock();
107 
108  $criterionAssignment2
109  ->expects($this->any())
110  ->method('getId')
111  ->willReturn(1);
112 
113  $criterionAssignment2
114  ->expects($this->any())
115  ->method('getCriterionId')
116  ->willReturn('usr_language');
117 
118  $criterionAssignment2
119  ->expects($this->any())
120  ->method('getCriterionValue')
121  ->willReturn($this->getCriterionConfig(['lng' => 'de']));
122 
123  $criterionAssignment3 = $this
124  ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
125  ->setMethods(['getId', 'getCriterionValue', 'getCriterionId'])
126  ->disableOriginalConstructor()
127  ->getMock();
128 
129  $criterionAssignment3
130  ->expects($this->any())
131  ->method('getId')
132  ->willReturn(0);
133 
134  $criterionAssignment3
135  ->expects($this->any())
136  ->method('getCriterionId')
137  ->willReturn('usr_language');
138 
139  $criterionAssignment3
140  ->expects($this->any())
141  ->method('getCriterionValue')
142  ->willReturn($this->getCriterionConfig(['lng' => 'de']));
143 
144  $criterionAssignment4 = $this
145  ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
146  ->disableOriginalConstructor()
147  ->setMethods(['getId', 'getCriterionValue', 'getCriterionId'])
148  ->getMock();
149 
150  $criterionAssignment4
151  ->expects($this->any())
152  ->method('getId')
153  ->willReturn(0);
154 
155  $criterionAssignment4
156  ->expects($this->any())
157  ->method('getCriterionId')
158  ->willReturn('usr_global_role');
159 
160  $criterionAssignment4
161  ->expects($this->any())
162  ->method('getCriterionValue')
163  ->willReturn($this->getCriterionConfig(['role_id' => 6]));
164 
165  return [
166  [$criterionAssignment1, $criterionAssignment2, $criterionAssignment3, $criterionAssignment4]
167  ];
168  }
+ Here is the call graph for this function:

◆ getCriterionTypeFactoryMock()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::getCriterionTypeFactoryMock ( )
protected
Returns
MockObject|ilTermsOfServiceCriterionTypeFactoryInterface
Exceptions
ReflectionException

Definition at line 17 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

Referenced by getTypeMockForConstraint(), and testCriterionWithSameNatureIsNotAcceptedWhenAlreadyAssigned().

18  {
19  $criterionTypeFactory = $this
20  ->getMockBuilder(ilTermsOfServiceCriterionTypeFactoryInterface::class)
21  ->getMock();
22 
23  return $criterionTypeFactory;
24  }
+ Here is the caller graph for this function:

◆ getCriterionTypeMock()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::getCriterionTypeMock ( string  $typeIdent)
protected
Parameters
string$typeIdent
Returns
MockObject|ilTermsOfServiceCriterionType
Exceptions
ReflectionException

Definition at line 31 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

Referenced by getTypeMockForConstraint(), and testCriterionWithSameNatureIsNotAcceptedWhenAlreadyAssigned().

32  {
33  $criterionType = $this
34  ->getMockBuilder(ilTermsOfServiceCriterionType::class)
35  ->getMock();
36 
37  $criterionType
38  ->expects($this->any())
39  ->method('getTypeIdent')
40  ->willReturn($typeIdent);
41 
42  return $criterionType;
43  }
Interface ilTermsOfServiceCriterionType.
+ Here is the caller graph for this function:

◆ getTypeMockForConstraint()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::getTypeMockForConstraint ( )
protected
Returns
MockObject|ilTermsOfServiceCriterionTypeFactoryInterface
Exceptions
ReflectionException

Definition at line 49 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References getCriterionTypeFactoryMock(), and getCriterionTypeMock().

Referenced by testConstraintAcceptanceWorksAsExpected(), testConstraintCheckWorksAsExpected(), testConstraintExposesCorrectErrorMessagesAfterMultiAccept(), testConstraintProblemBuilderWorksAsExpected(), testConstraintProblemDetectionWorksAsExpected(), and testConstraintRestrictionWorksAsExpected().

50  {
51  $criterionTypeFactory = $this->getCriterionTypeFactoryMock();
52 
53  $criterionType1 = $this->getCriterionTypeMock('dummy');
54 
55  $criterionType1
56  ->expects($this->any())
57  ->method('hasUniqueNature')
58  ->willReturn(false);
59 
60  $criterionTypeFactory
61  ->expects($this->any())
62  ->method('getTypesByIdentMap')
63  ->willReturn([
64  $criterionType1->getTypeIdent() => $criterionType1,
65  ]);
66 
67  $criterionTypeFactory
68  ->expects($this->any())
69  ->method('findByTypeIdent')
70  ->willReturn($criterionType1);
71 
72  return $criterionTypeFactory;
73  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testConstraintAcceptanceWorksAsExpected()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::testConstraintAcceptanceWorksAsExpected ( ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment1,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment2,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment3,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment4 
)

criteriaAssignmentProvider

Parameters
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment1
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment2
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment3
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment4
Exceptions
ReflectionException

Definition at line 178 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References ilTermsOfServiceBaseTest\getLanguageMock(), and getTypeMockForConstraint().

183  : void {
184  $document1 = $this
185  ->getMockBuilder(ilTermsOfServiceDocument::class)
186  ->disableOriginalConstructor()
187  ->setMethods(['criteria'])
188  ->getMock();
189 
190  $document1
191  ->expects($this->any())
192  ->method('criteria')
193  ->willReturn([$criterionAssignment1, $criterionAssignment2]);
194 
196  $this->getTypeMockForConstraint(),
197  $document1,
198  new Factory(),
199  $this->getLanguageMock()
200  );
201 
202  $this->assertTrue($constraint->accepts($criterionAssignment1));
203  $this->assertTrue($constraint->accepts($criterionAssignment2));
204  $this->assertFalse($constraint->accepts($criterionAssignment3));
205  $this->assertTrue($constraint->accepts($criterionAssignment4));
206  }
Builds data types.
Definition: Factory.php:19
+ Here is the call graph for this function:

◆ testConstraintCheckWorksAsExpected()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::testConstraintCheckWorksAsExpected ( ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment1,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment2,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment3,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment4 
)

criteriaAssignmentProvider

Parameters
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment1
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment2
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment3
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment4
Exceptions
ReflectionException

Definition at line 216 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References Vendor\Package\$e, ilTermsOfServiceBaseTest\getLanguageMock(), and getTypeMockForConstraint().

221  : void {
222  $document1 = $this
223  ->getMockBuilder(ilTermsOfServiceDocument::class)
224  ->disableOriginalConstructor()
225  ->setMethods(['criteria'])
226  ->getMock();
227 
228  $document1
229  ->expects($this->any())
230  ->method('criteria')
231  ->willReturn([$criterionAssignment1, $criterionAssignment2]);
232 
234  $this->getTypeMockForConstraint(),
235  $document1,
236  new Factory(),
237  $this->getLanguageMock()
238  );
239 
240  $raised = false;
241 
242  try {
243  $constraint->check($criterionAssignment4);
244  } catch (UnexpectedValueException $e) {
245  $raised = true;
246  }
247 
248  $this->assertFalse($raised);
249 
250  try {
251  $constraint->check($criterionAssignment3);
252  $raised = false;
253  } catch (UnexpectedValueException $e) {
254  $this->assertEquals('The passed assignment must be unique for the document!', $e->getMessage());
255  $raised = true;
256  }
257 
258  $this->assertTrue($raised);
259  }
Builds data types.
Definition: Factory.php:19
+ Here is the call graph for this function:

◆ testConstraintExposesCorrectErrorMessagesAfterMultiAccept()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::testConstraintExposesCorrectErrorMessagesAfterMultiAccept ( ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment1,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment2,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment3,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment4 
)

criteriaAssignmentProvider

Parameters
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment1
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment2
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment3
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment4
Exceptions
ReflectionException

Definition at line 393 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References ilTermsOfServiceBaseTest\getLanguageMock(), and getTypeMockForConstraint().

398  : void {
399  $document1 = $this
400  ->getMockBuilder(ilTermsOfServiceDocument::class)
401  ->disableOriginalConstructor()
402  ->setMethods(['criteria'])
403  ->getMock();
404 
405  $document1
406  ->expects($this->any())
407  ->method('criteria')
408  ->willReturn([$criterionAssignment1, $criterionAssignment2]);
409 
411  $this->getTypeMockForConstraint(),
412  $document1,
413  new Factory(),
414  $this->getLanguageMock()
415  );
416 
417  $criterionAssignment5 = clone $criterionAssignment3;
418 
419  $constraint->accepts($criterionAssignment1);
420  $constraint->accepts($criterionAssignment2);
421  $constraint->accepts($criterionAssignment3);
422  $constraint->accepts($criterionAssignment4);
423  $constraint->accepts($criterionAssignment5);
424 
425  $this->assertEquals(
426  'The passed assignment must be unique for the document!',
427  $constraint->problemWith($criterionAssignment3)
428  );
429  $this->assertEquals(
430  'The passed assignment must be unique for the document!',
431  $constraint->problemWith($criterionAssignment5)
432  );
433  }
Builds data types.
Definition: Factory.php:19
+ Here is the call graph for this function:

◆ testConstraintProblemBuilderWorksAsExpected()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::testConstraintProblemBuilderWorksAsExpected ( ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment1,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment2,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment3,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment4 
)

criteriaAssignmentProvider

Parameters
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment1
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment2
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment3
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment4
Exceptions
ReflectionException

Definition at line 355 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References ilTermsOfServiceBaseTest\getLanguageMock(), and getTypeMockForConstraint().

360  : void {
361  $document1 = $this
362  ->getMockBuilder(ilTermsOfServiceDocument::class)
363  ->disableOriginalConstructor()
364  ->setMethods(['criteria'])
365  ->getMock();
366 
367  $document1
368  ->expects($this->any())
369  ->method('criteria')
370  ->willReturn([$criterionAssignment1, $criterionAssignment2]);
371 
373  $this->getTypeMockForConstraint(),
374  $document1,
375  new Factory(),
376  $this->getLanguageMock()
377  );
378 
379  $newConstraint = $constraint->withProblemBuilder(function () {
380  return 'phpunit';
381  });
382  $this->assertEquals('phpunit', $newConstraint->problemWith($criterionAssignment3));
383  }
Builds data types.
Definition: Factory.php:19
+ Here is the call graph for this function:

◆ testConstraintProblemDetectionWorksAsExpected()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::testConstraintProblemDetectionWorksAsExpected ( ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment1,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment2,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment3,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment4 
)

criteriaAssignmentProvider

Parameters
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment1
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment2
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment3
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment4
Exceptions
ReflectionException

Definition at line 269 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References ilTermsOfServiceBaseTest\getLanguageMock(), and getTypeMockForConstraint().

274  : void {
275  $document1 = $this
276  ->getMockBuilder(ilTermsOfServiceDocument::class)
277  ->disableOriginalConstructor()
278  ->setMethods(['criteria'])
279  ->getMock();
280 
281  $document1
282  ->expects($this->any())
283  ->method('criteria')
284  ->willReturn([$criterionAssignment1, $criterionAssignment2]);
285 
287  $this->getTypeMockForConstraint(),
288  $document1,
289  new Factory(),
290  $this->getLanguageMock()
291  );
292 
293  $this->assertNull($constraint->problemWith($criterionAssignment1));
294  $this->assertNull($constraint->problemWith($criterionAssignment2));
295  $this->assertNull($constraint->problemWith($criterionAssignment4));
296  $this->assertIsString($constraint->problemWith($criterionAssignment3));
297  }
Builds data types.
Definition: Factory.php:19
+ Here is the call graph for this function:

◆ testConstraintRestrictionWorksAsExpected()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::testConstraintRestrictionWorksAsExpected ( ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment1,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment2,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment3,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment4 
)

criteriaAssignmentProvider

Parameters
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment1
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment2
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment3
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment4
Exceptions
ReflectionException

Definition at line 307 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References $ok, $result, ilTermsOfServiceBaseTest\getLanguageMock(), and getTypeMockForConstraint().

312  : void {
313  $document1 = $this
314  ->getMockBuilder(ilTermsOfServiceDocument::class)
315  ->disableOriginalConstructor()
316  ->setMethods(['criteria'])
317  ->getMock();
318 
319  $document1
320  ->expects($this->any())
321  ->method('criteria')
322  ->willReturn([$criterionAssignment1, $criterionAssignment2]);
323 
324  $dataFavtgory = new Factory();
325 
327  $this->getTypeMockForConstraint(),
328  $document1,
329  $dataFavtgory,
330  $this->getLanguageMock()
331  );
332 
333  $ok = $dataFavtgory->ok($criterionAssignment1);
334  $ok2 = $dataFavtgory->ok($criterionAssignment3);
335  $error = $dataFavtgory->error('An error occurred');
336 
337  $result = $constraint->applyTo($ok);
338  $this->assertTrue($result->isOk());
339 
340  $result = $constraint->applyTo($ok2);
341  $this->assertTrue($result->isError());
342 
343  $result = $constraint->applyTo($error);
344  $this->assertSame($error, $result);
345  }
$result
Builds data types.
Definition: Factory.php:19
+ Here is the call graph for this function:

◆ testCriterionWithSameNatureIsNotAcceptedWhenAlreadyAssigned()

ilTermsOfServiceDocumentCriterionAssignmentConstraintTest::testCriterionWithSameNatureIsNotAcceptedWhenAlreadyAssigned ( ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment1,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment2,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment3,
ilTermsOfServiceDocumentCriterionAssignment  $criterionAssignment4 
)

criteriaAssignmentProvider

Parameters
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment1
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment2
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment3
ilTermsOfServiceDocumentCriterionAssignment$criterionAssignment4
Exceptions
ReflectionException

Definition at line 443 of file ilTermsOfServiceDocumentCriterionAssignmentConstraintTest.php.

References ilTermsOfServiceBaseTest\getCriterionConfig(), getCriterionTypeFactoryMock(), getCriterionTypeMock(), and ilTermsOfServiceBaseTest\getLanguageMock().

448  : void {
449  $document = $this
450  ->getMockBuilder(ilTermsOfServiceDocument::class)
451  ->disableOriginalConstructor()
452  ->setMethods(['criteria'])
453  ->getMock();
454 
455  $document
456  ->expects($this->any())
457  ->method('criteria')
458  ->willReturn([$criterionAssignment1, $criterionAssignment2]);
459 
460  $criterionTypeFactory = $this->getCriterionTypeFactoryMock();
461 
462  $criterionType1 = $this->getCriterionTypeMock('usr_global_role');
463  $criterionType2 = $this->getCriterionTypeMock('usr_language');
464 
465  $criterionType1
466  ->expects($this->any())
467  ->method('hasUniqueNature')
468  ->willReturn(false);
469 
470  $criterionType2
471  ->expects($this->any())
472  ->method('hasUniqueNature')
473  ->willReturn(true);
474 
475  $criterionTypeFactory
476  ->expects($this->any())
477  ->method('findByTypeIdent')
478  ->willReturn($criterionType2);
479 
481  $criterionTypeFactory,
482  $document,
483  new Factory(),
484  $this->getLanguageMock()
485  );
486 
487  $criterionWithSameNature = $this
488  ->getMockBuilder(ilTermsOfServiceDocumentCriterionAssignment::class)
489  ->setMethods(['getId', 'getCriterionValue', 'getCriterionId'])
490  ->disableOriginalConstructor()
491  ->getMock();
492 
493  $criterionWithSameNature
494  ->expects($this->any())
495  ->method('getId')
496  ->willReturn(0);
497 
498  $criterionWithSameNature
499  ->expects($this->any())
500  ->method('getCriterionId')
501  ->willReturn('usr_language');
502 
503  $criterionWithSameNature
504  ->expects($this->any())
505  ->method('getCriterionValue')
506  ->willReturn($this->getCriterionConfig(['lng' => 'ru']));
507 
508  $this->assertFalse($constraint->accepts($criterionWithSameNature));
509  }
Builds data types.
Definition: Factory.php:19
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: