ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceDocumentEvaluationTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
14  {
15  $evaluator = $this->getEvaluatorMock();
16  $user = $this->getUserMock();
17  $log = $this->getLogMock();
18 
19  $evaluation = new \ilTermsOfServiceSequentialDocumentEvaluation(
20  $evaluator,
21  $user,
22  $log,
23  []
24  );
25 
26  $this->assertFalse($evaluation->hasDocument());
27  }
28 
33  {
34  $evaluator = $this->getEvaluatorMock();
35  $user = $this->getUserMock();
36  $log = $this->getLogMock();
37 
38  $evaluation = new \ilTermsOfServiceSequentialDocumentEvaluation(
39  $evaluator,
40  $user,
41  $log,
42  []
43  );
44 
45  $this->assertException(\ilTermsOfServiceNoSignableDocumentFoundException::class);
46 
47  $evaluation->document();
48  }
49 
54  {
55  $evaluator = $this->getEvaluatorMock();
56  $user = $this->getUserMock();
57  $log = $this->getLogMock();
58 
59  $doc = $this
60  ->getMockBuilder(\ilTermsOfServiceSignableDocument::class)
61  ->getMock();
62 
63  $evaluator
64  ->expects($this->exactly(1))
65  ->method('evaluate')
66  ->with($doc)
67  ->willReturn(true);
68 
69  $evaluation = new \ilTermsOfServiceSequentialDocumentEvaluation(
70  $evaluator,
71  $user,
72  $log,
73  [$doc]
74  );
75 
76  $this->assertTrue($evaluation->hasDocument());
77  $this->assertEquals($doc, $evaluation->document());
78  }
79 
84  {
85  $evaluator = $this->getEvaluatorMock();
86  $user = $this->getUserMock();
87  $log = $this->getLogMock();
88 
89  $doc1 = $this
90  ->getMockBuilder(\ilTermsOfServiceSignableDocument::class)
91  ->getMock();
92 
93  $doc2 = $this
94  ->getMockBuilder(\ilTermsOfServiceSignableDocument::class)
95  ->getMock();
96 
97  $doc3 = $this
98  ->getMockBuilder(\ilTermsOfServiceSignableDocument::class)
99  ->getMock();
100 
101  $evaluator
102  ->expects($this->exactly(3))
103  ->method('evaluate')
104  ->withConsecutive(
105  [$doc1],
106  [$doc2],
107  [$doc3]
108  )
109  ->will($this->returnValueMap([
110  [$doc1, false],
111  [$doc2, true],
112  [$doc3, false]
113  ]));
114 
115  $evaluation = new \ilTermsOfServiceSequentialDocumentEvaluation(
116  $evaluator,
117  $user,
118  $log,
119  [$doc1, $doc2, $doc3]
120  );
121 
122  $this->assertTrue($evaluation->hasDocument());
123  $this->assertEquals($doc2, $evaluation->document());
124  }
125 
130  {
131  $evaluator = $this->getEvaluatorMock();
132  $user = $this->getUserMock();
133  $log = $this->getLogMock();
134 
135  $doc1 = $this
136  ->getMockBuilder(\ilTermsOfServiceSignableDocument::class)
137  ->getMock();
138 
139  $doc2 = $this
140  ->getMockBuilder(\ilTermsOfServiceSignableDocument::class)
141  ->getMock();
142 
143  $doc3 = $this
144  ->getMockBuilder(\ilTermsOfServiceSignableDocument::class)
145  ->getMock();
146 
147  $evaluator
148  ->expects($this->exactly(3))
149  ->method('evaluate')
150  ->withConsecutive(
151  [$doc1],
152  [$doc2],
153  [$doc3]
154  )
155  ->will($this->returnValueMap([
156  [$doc1, false],
157  [$doc2, true],
158  [$doc3, true]
159  ]));
160 
161  $evaluation = new \ilTermsOfServiceSequentialDocumentEvaluation(
162  $evaluator,
163  $user,
164  $log,
165  [$doc1, $doc2, $doc3]
166  );
167 
168  $this->assertTrue($evaluation->hasDocument());
169  $this->assertEquals($doc2, $evaluation->document());
170  }
171 }
assertException(string $exceptionClass)
$log
Definition: sabredav.php:21
Class ilTermsOfServiceAcceptanceEntityTest.
$user
Definition: migrateto20.php:57
Class ilTermsOfServiceEvaluationBaseTest.