ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceDocumentEvaluationTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
28  {
29  $evaluator = $this->getEvaluatorMock();
30  $user = $this->getUserMock();
31  $log = $this->getLogMock();
32 
34  $evaluator,
35  $user,
36  $log,
37  []
38  );
39 
40  $this->assertFalse($evaluation->hasDocument());
41  }
42 
44  {
45  $evaluator = $this->getEvaluatorMock();
46  $user = $this->getUserMock();
47  $log = $this->getLogMock();
48 
50  $evaluator,
51  $user,
52  $log,
53  []
54  );
55 
56  $this->expectException(ilTermsOfServiceNoSignableDocumentFoundException::class);
57 
58  $evaluation->document();
59  }
60 
62  {
63  $evaluator = $this->getEvaluatorMock();
64  $user = $this->getUserMock();
65  $log = $this->getLogMock();
66 
67  $doc = $this
68  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
69  ->getMock();
70 
71  $evaluator
72  ->expects($this->once())
73  ->method('evaluate')
74  ->with($doc)
75  ->willReturn(true);
76 
78  $evaluator,
79  $user,
80  $log,
81  [$doc]
82  );
83 
84  $this->assertTrue($evaluation->hasDocument());
85  $this->assertSame($doc, $evaluation->document());
86  }
87 
89  {
90  $evaluator = $this->getEvaluatorMock();
91  $user = $this->getUserMock();
92  $log = $this->getLogMock();
93 
94  $doc1 = $this
95  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
96  ->getMock();
97 
98  $doc2 = $this
99  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
100  ->getMock();
101 
102  $doc3 = $this
103  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
104  ->getMock();
105 
106  $evaluator
107  ->expects($this->exactly(3))
108  ->method('evaluate')
109  ->withConsecutive(
110  [$doc1],
111  [$doc2],
112  [$doc3]
113  )
114  ->willReturnMap([
115  [$doc1, false],
116  [$doc2, true],
117  [$doc3, false],
118  ]);
119 
121  $evaluator,
122  $user,
123  $log,
124  [$doc1, $doc2, $doc3]
125  );
126 
127  $this->assertTrue($evaluation->hasDocument());
128  $this->assertSame($doc2, $evaluation->document());
129  }
130 
132  {
133  $evaluator = $this->getEvaluatorMock();
134  $user = $this->getUserMock();
135  $log = $this->getLogMock();
136 
137  $doc1 = $this
138  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
139  ->getMock();
140 
141  $doc2 = $this
142  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
143  ->getMock();
144 
145  $doc3 = $this
146  ->getMockBuilder(ilTermsOfServiceSignableDocument::class)
147  ->getMock();
148 
149  $evaluator
150  ->expects($this->exactly(3))
151  ->method('evaluate')
152  ->withConsecutive(
153  [$doc1],
154  [$doc2],
155  [$doc3]
156  )
157  ->willReturnMap([
158  [$doc1, false],
159  [$doc2, true],
160  [$doc3, true],
161  ]);
162 
164  $evaluator,
165  $user,
166  $log,
167  [$doc1, $doc2, $doc3]
168  );
169 
170  $this->assertTrue($evaluation->hasDocument());
171  $this->assertSame($doc2, $evaluation->document());
172  }
173 }
Interface ilTermsOfServiceSequentialDocumentEvaluation.
Class ilTermsOfServiceAcceptanceEntityTest.
$log
Definition: result.php:33
Class ilTermsOfServiceEvaluationBaseTest.