ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
 setGlobalVariable (string $name, $value)
 
 assertException (string $exceptionClass)
 
 getCriterionConfig ($value=null)
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
 $dic
 

Detailed Description

Member Function Documentation

◆ testLogicalAndEvaluatorReturnsFalseIfAnyCriteriaAttachedToADocumentDoesNotMatch()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsFalseIfAnyCriteriaAttachedToADocumentDoesNotMatch ( )

Definition at line 101 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

References $log, $user, ilTermsOfServiceEvaluationBaseTest\getCriterionAssignmentMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeFactoryMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeMock(), ilTermsOfServiceEvaluationBaseTest\getLogMock(), ilTermsOfServiceEvaluationBaseTest\getUserMock(), and Sabre\Event\once().

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

◆ testLogicalAndEvaluatorReturnsTrueIfAllCriteriaAttachedToADocumentMatch()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsTrueIfAllCriteriaAttachedToADocumentMatch ( )

Definition at line 36 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

References $log, $user, ilTermsOfServiceEvaluationBaseTest\getCriterionAssignmentMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeFactoryMock(), ilTermsOfServiceEvaluationBaseTest\getCriterionTypeMock(), ilTermsOfServiceEvaluationBaseTest\getLogMock(), ilTermsOfServiceEvaluationBaseTest\getUserMock(), and Sabre\Event\once().

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 
84  $criterionTypeFactory
85  ->expects($this->exactly(3))
86  ->method('findByTypeIdent')
87  ->willReturnOnConsecutiveCalls(
88  $criterionType1,
89  $criterionType2,
90  $criterionType3
91  );
92 
93  $evaluator = new \ilTermsOfServiceLogicalAndDocumentCriteriaEvaluation($criterionTypeFactory, $user, $log);
94 
95  $this->assertTrue($evaluator->evaluate($doc));
96  }
$log
Definition: sabredav.php:21
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$user
Definition: migrateto20.php:57
getCriterionAssignmentMock(\ilTermsOfServiceCriterionType $criterionType)
+ Here is the call graph for this function:

◆ testLogicalAndEvaluatorReturnsTrueIfNoCriterionIsAttachedToADocumentAtAll()

ilTermsOfServiceDocumentCriteriaEvaluationTest::testLogicalAndEvaluatorReturnsTrueIfNoCriterionIsAttachedToADocumentAtAll ( )

Definition at line 13 of file ilTermsOfServiceDocumentCriteriaEvaluationTest.php.

References $log, $user, ilTermsOfServiceEvaluationBaseTest\getCriterionTypeFactoryMock(), ilTermsOfServiceEvaluationBaseTest\getLogMock(), ilTermsOfServiceEvaluationBaseTest\getUserMock(), and Sabre\Event\once().

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: sabredav.php:21
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$user
Definition: migrateto20.php:57
+ Here is the call graph for this function:

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