ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 

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
 $dic
 

Detailed Description

Member Function Documentation

◆ testLogicalAndEvaluatorReturnsFalseIfAnyCriteriaAttachedToADocumentDoesNotMatch()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsFalseIfAnyCriteriaAttachedToADocumentDoesNotMatch ( )
Exceptions
ReflectionException

Definition at line 100 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

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

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

◆ testLogicalAndEvaluatorReturnsTrueIfAllCriteriaAttachedToADocumentMatch()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsTrueIfAllCriteriaAttachedToADocumentMatch ( )
Exceptions
ReflectionException

Definition at line 36 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

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

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

◆ testLogicalAndEvaluatorReturnsTrueIfNoCriterionIsAttachedToADocumentAtAll()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsTrueIfNoCriterionIsAttachedToADocumentAtAll ( )
Exceptions
ReflectionException

Definition at line 13 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

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

13  : void
14  {
15  $user = $this->getUserMock();
16  $criterionTypeFactory = $this->getCriterionTypeFactoryMock();
17  $log = $this->getLogMock();
18 
19  $doc = $this
20  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
21  ->getMock();
22 
23  $doc
24  ->expects($this->once())
25  ->method('criteria')
26  ->willReturn([]);
27 
28  $evaluator = new ilTermsOfServiceLogicalAndDocumentCriteriaEvaluation($criterionTypeFactory, $user, $log);
29 
30  $this->assertTrue($evaluator->evaluate($doc));
31  }
$log
Definition: result.php:15
+ Here is the call graph for this function:

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