ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceDocumentCriteriaEvaluationTest Class Reference

Class ilTermsOfServiceDocumentCriteriaEvaluationTest. More...

+ Inheritance diagram for ilTermsOfServiceDocumentCriteriaEvaluationTest:
+ Collaboration diagram for ilTermsOfServiceDocumentCriteriaEvaluationTest:

Public Member Functions

 testLogicalAndEvaluatorReturnsTrueIfNoCriterionIsAttachedToADocumentAtAll ()
 
 testLogicalAndEvaluatorReturnsTrueIfAllCriteriaAttachedToADocumentMatch ()
 
 testLogicalAndEvaluatorReturnsFalseIfAnyCriteriaAttachedToADocumentDoesNotMatch ()
 
 testMutatingTheContextUserResultsInANewInstance ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilTermsOfServiceEvaluationBaseTest
 getUserMock ()
 
 getLogMock ()
 
 getEvaluatorMock ()
 
 getCriterionTypeFactoryMock ()
 
 getCriterionTypeMock (string $typeIdent)
 
 getCriterionAssignmentMock (ilTermsOfServiceCriterionType $criterionType)
 
- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
Container $dic
 

Detailed Description

Member Function Documentation

◆ testLogicalAndEvaluatorReturnsFalseIfAnyCriteriaAttachedToADocumentDoesNotMatch()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsFalseIfAnyCriteriaAttachedToADocumentDoesNotMatch ( )

Definition at line 108 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

References $log, ilTermsOfServiceEvaluationBaseTest\getCriterionAssignmentMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeFactoryMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeMock(), ilTermsOfServiceEvaluationBaseTest\getLogMock(), and ilTermsOfServiceEvaluationBaseTest\getUserMock().

108  : void
109  {
110  $user = $this->getUserMock();
111  $log = $this->getLogMock();
112 
113  $criterionTypeFactory = $this->getCriterionTypeFactoryMock();
114 
115  $criterionType1 = $this->getCriterionTypeMock('dummy1');
116  $criterionAssignment1 = $this->getCriterionAssignmentMock($criterionType1);
117 
118  $criterionType2 = $this->getCriterionTypeMock('dummy2');
119  $criterionAssignment2 = $this->getCriterionAssignmentMock($criterionType2);
120 
121  $criterionType3 = $this->getCriterionTypeMock('dummy3');
122  $criterionAssignment3 = $this->getCriterionAssignmentMock($criterionType3);
123 
124  $criterionType1
125  ->expects($this->once())
126  ->method('evaluate')
127  ->with($user)
128  ->willReturn(true);
129 
130  $criterionType2
131  ->expects($this->once())
132  ->method('evaluate')
133  ->with($user)
134  ->willReturn(false);
135 
136  $criterionType3
137  ->expects($this->never())
138  ->method('evaluate')
139  ->with($user)
140  ->willReturn(true);
141 
142  $doc = $this
143  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
144  ->getMock();
145 
146  $doc
147  ->expects($this->once())
148  ->method('criteria')
149  ->willReturn([
150  $criterionAssignment1,
151  $criterionAssignment2,
152  $criterionAssignment3
153  ]);
154 
155  $criterionTypeFactory
156  ->expects($this->exactly(2))
157  ->method('findByTypeIdent')
158  ->willReturnOnConsecutiveCalls(
159  $criterionType1,
160  $criterionType2,
161  $criterionType3
162  );
163 
164  $evaluator = new ilTermsOfServiceLogicalAndDocumentCriteriaEvaluation($criterionTypeFactory, $user, $log);
165 
166  $this->assertFalse($evaluator->evaluate($doc));
167  }
getCriterionAssignmentMock(ilTermsOfServiceCriterionType $criterionType)
$log
Definition: result.php:33
+ Here is the call graph for this function:

◆ testLogicalAndEvaluatorReturnsTrueIfAllCriteriaAttachedToADocumentMatch()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsTrueIfAllCriteriaAttachedToADocumentMatch ( )

Definition at line 47 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

References $log, ilTermsOfServiceEvaluationBaseTest\getCriterionAssignmentMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeFactoryMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeMock(), ilTermsOfServiceEvaluationBaseTest\getLogMock(), and ilTermsOfServiceEvaluationBaseTest\getUserMock().

47  : void
48  {
49  $user = $this->getUserMock();
50  $log = $this->getLogMock();
51 
52  $criterionTypeFactory = $this->getCriterionTypeFactoryMock();
53 
54  $criterionType1 = $this->getCriterionTypeMock('dummy1');
55  $criterionAssignment1 = $this->getCriterionAssignmentMock($criterionType1);
56 
57  $criterionType2 = $this->getCriterionTypeMock('dummy2');
58  $criterionAssignment2 = $this->getCriterionAssignmentMock($criterionType2);
59 
60  $criterionType3 = $this->getCriterionTypeMock('dummy3');
61  $criterionAssignment3 = $this->getCriterionAssignmentMock($criterionType3);
62 
63  $criterionType1
64  ->expects($this->once())
65  ->method('evaluate')
66  ->with($user)
67  ->willReturn(true);
68 
69  $criterionType2
70  ->expects($this->once())
71  ->method('evaluate')
72  ->with($user)
73  ->willReturn(true);
74 
75  $criterionType3
76  ->expects($this->once())
77  ->method('evaluate')
78  ->with($user)
79  ->willReturn(true);
80 
81  $doc = $this
82  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
83  ->getMock();
84 
85  $doc
86  ->expects($this->once())
87  ->method('criteria')
88  ->willReturn([
89  $criterionAssignment1,
90  $criterionAssignment2,
91  $criterionAssignment3
92  ]);
93 
94  $criterionTypeFactory
95  ->expects($this->exactly(3))
96  ->method('findByTypeIdent')
97  ->willReturnOnConsecutiveCalls(
98  $criterionType1,
99  $criterionType2,
100  $criterionType3
101  );
102 
103  $evaluator = new ilTermsOfServiceLogicalAndDocumentCriteriaEvaluation($criterionTypeFactory, $user, $log);
104 
105  $this->assertTrue($evaluator->evaluate($doc));
106  }
getCriterionAssignmentMock(ilTermsOfServiceCriterionType $criterionType)
$log
Definition: result.php:33
+ Here is the call graph for this function:

◆ testLogicalAndEvaluatorReturnsTrueIfNoCriterionIsAttachedToADocumentAtAll()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsTrueIfNoCriterionIsAttachedToADocumentAtAll ( )

Definition at line 27 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

References $log, ilTermsOfServiceEvaluationBaseTest\getCriterionTypeFactoryMock(), ilTermsOfServiceEvaluationBaseTest\getLogMock(), and ilTermsOfServiceEvaluationBaseTest\getUserMock().

27  : void
28  {
29  $user = $this->getUserMock();
30  $criterionTypeFactory = $this->getCriterionTypeFactoryMock();
31  $log = $this->getLogMock();
32 
33  $doc = $this
34  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
35  ->getMock();
36 
37  $doc
38  ->expects($this->once())
39  ->method('criteria')
40  ->willReturn([]);
41 
42  $evaluator = new ilTermsOfServiceLogicalAndDocumentCriteriaEvaluation($criterionTypeFactory, $user, $log);
43 
44  $this->assertTrue($evaluator->evaluate($doc));
45  }
$log
Definition: result.php:33
+ Here is the call graph for this function:

◆ testMutatingTheContextUserResultsInANewInstance()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testMutatingTheContextUserResultsInANewInstance ( )

Definition at line 169 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

References ilTermsOfServiceEvaluationBaseTest\getCriterionTypeFactoryMock(), ilTermsOfServiceEvaluationBaseTest\getLogMock(), and ilTermsOfServiceEvaluationBaseTest\getUserMock().

169  : void
170  {
173  $this->getUserMock(),
174  $this->getLogMock()
175  );
176 
177  $this->assertNotSame($evaluator, $evaluator->withContextUser($this->getUserMock()));
178  }
+ Here is the call graph for this function:

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