ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceDocumentEvaluationTest.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
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 
20  $evaluator,
21  $user,
22  $log,
23  []
24  );
25 
26  $this->assertFalse($evaluation->hasDocument());
27  }
28 
34  {
35  $evaluator = $this->getEvaluatorMock();
36  $user = $this->getUserMock();
37  $log = $this->getLogMock();
38 
40  $evaluator,
41  $user,
42  $log,
43  []
44  );
45 
46  $this->expectException(ilTermsOfServiceNoSignableDocumentFoundException::class);
47 
48  $evaluation->document();
49  }
50 
56  {
57  $evaluator = $this->getEvaluatorMock();
58  $user = $this->getUserMock();
59  $log = $this->getLogMock();
60 
61  $doc = $this
62  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
63  ->getMock();
64 
65  $evaluator
66  ->expects($this->exactly(1))
67  ->method('evaluate')
68  ->with($doc)
69  ->willReturn(true);
70 
72  $evaluator,
73  $user,
74  $log,
75  [$doc]
76  );
77 
78  $this->assertTrue($evaluation->hasDocument());
79  $this->assertEquals($doc, $evaluation->document());
80  }
81 
87  {
88  $evaluator = $this->getEvaluatorMock();
89  $user = $this->getUserMock();
90  $log = $this->getLogMock();
91 
92  $doc1 = $this
93  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
94  ->getMock();
95 
96  $doc2 = $this
97  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
98  ->getMock();
99 
100  $doc3 = $this
101  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
102  ->getMock();
103 
104  $evaluator
105  ->expects($this->exactly(3))
106  ->method('evaluate')
107  ->withConsecutive(
108  [$doc1],
109  [$doc2],
110  [$doc3]
111  )
112  ->will($this->returnValueMap([
113  [$doc1, false],
114  [$doc2, true],
115  [$doc3, false],
116  ]));
117 
119  $evaluator,
120  $user,
121  $log,
122  [$doc1, $doc2, $doc3]
123  );
124 
125  $this->assertTrue($evaluation->hasDocument());
126  $this->assertEquals($doc2, $evaluation->document());
127  }
128 
134  {
135  $evaluator = $this->getEvaluatorMock();
136  $user = $this->getUserMock();
137  $log = $this->getLogMock();
138 
139  $doc1 = $this
140  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
141  ->getMock();
142 
143  $doc2 = $this
144  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
145  ->getMock();
146 
147  $doc3 = $this
148  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
149  ->getMock();
150 
151  $evaluator
152  ->expects($this->exactly(3))
153  ->method('evaluate')
154  ->withConsecutive(
155  [$doc1],
156  [$doc2],
157  [$doc3]
158  )
159  ->will($this->returnValueMap([
160  [$doc1, false],
161  [$doc2, true],
162  [$doc3, true],
163  ]));
164 
166  $evaluator,
167  $user,
168  $log,
169  [$doc1, $doc2, $doc3]
170  );
171 
172  $this->assertTrue($evaluation->hasDocument());
173  $this->assertEquals($doc2, $evaluation->document());
174  }
175 }
Interface ilTermsOfServiceSequentialDocumentEvaluation.
Class ilTermsOfServiceAcceptanceEntityTest.
$log
Definition: result.php:15
Class ilTermsOfServiceEvaluationBaseTest.