ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateLearningHistoryProviderTest Class Reference
+ Inheritance diagram for ilCertificateLearningHistoryProviderTest:
+ Collaboration diagram for ilCertificateLearningHistoryProviderTest:

Public Member Functions

 testIsActive ()
 
 testGetEntries ()
 
 testGetName ()
 

Detailed Description

Definition at line 3 of file ilCertificateLearningHistoryProviderTest.php.

Member Function Documentation

◆ testGetEntries()

ilCertificateLearningHistoryProviderTest::testGetEntries ( )

Definition at line 62 of file ilCertificateLearningHistoryProviderTest.php.

References $language, PHPMailer\PHPMailer\$provider, and $template.

63  {
64  $learningHistoryFactory = $this->getMockBuilder('ilLearningHistoryFactory')
65  ->disableOriginalConstructor()
66  ->getMock();
67 
68  $language = $this->getMockBuilder('ilLanguage')
69  ->disableOriginalConstructor()
70  ->getMock();
71 
72  $language->method('txt')
73  ->willReturnOnConsecutiveCalls(
74  'Certificate for %1$s',
75  '%1$s achieved.',
76  'Certificate for %1$s',
77  '%1$s achieved.'
78  );
79 
80  $dic = $this->getMockBuilder('\ILIAS\DI\Container')
81  ->disableOriginalConstructor()
82  ->getMock();
83 
84  $template = $this->getMockBuilder('ilTemplate')
85  ->disableOriginalConstructor()
86  ->getMock();
87 
88  $template->method('get')
89  ->willReturnOnConsecutiveCalls('Course Title', 'Test Title');
90 
91  $userCertificateRepository = $this->getMockBuilder('ilUserCertificateRepository')
92  ->disableOriginalConstructor()
93  ->getMock();
94 
95  $userCertificateRepository->method('fetchActiveCertificatesInIntervalForPresentation')
96  ->willReturn(
97  array(
100  1,
101  200,
102  'crs',
103  300,
104  'Ilyas Odys',
105  123456789,
106  '<xml>Some Content</xml>',
107  '["SOME_PLACEHOLDER"]',
108  null,
109  1,
110  'v5.4.0',
111  true,
112  '/some/where/background_1.jpg',
113  '/some/where/else/thumbnail_1.jpg',
114  40
115  ),
116  'Course Title',
117  'Course Description'
118  ),
120  new ilUserCertificate(
121  5,
122  500,
123  'tst',
124  5000,
125  'Ilyas Odys',
126  987654321,
127  '<xml>Some Content</xml>',
128  '["SOME_PLACEHOLDER"]',
129  null,
130  1,
131  'v5.4.0',
132  true,
133  '/some/where/background_1.jpg',
134  '/some/where/else/thumbnail_1.jpg',
135  50
136  ),
137  'Test Title',
138  'Test Description'
139  )
140  )
141  );
142 
143  $controller = $this->getMockBuilder('ilCtrl')
144  ->disableOriginalConstructor()
145  ->getMock();
146 
147  $controller
148  ->expects($this->exactly(2))
149  ->method('getLinkTargetByClass')
150  ->willReturn('<a href> </a>');
151 
152  $controller
153  ->expects($this->exactly(2))
154  ->method('clearParametersByClass');
155 
156  $controller
157  ->expects($this->exactly(2))
158  ->method('setParameterByClass');
159 
160  $certificateSettings = $this->getMockBuilder('ilSetting')
161  ->disableOriginalConstructor()
162  ->getMock();
163 
164  $certificateSettings->method('get')
165  ->willReturn(true);
166 
167  $uiFactory = $this->getMockBuilder('ILIAS\UI\Factory')
168  ->disableOriginalConstructor()
169  ->getMock();
170 
171  $link = $this->getMockBuilder('\ILIAS\UI\Component\Link\Factory')
172  ->disableOriginalConstructor()
173  ->getMock();
174 
175  $link->method('standard')
176  ->withConsecutive(
177  array('Course Title', '<a href> </a>'),
178  array('Test Title', '<a href> </a>')
179  )
180  ->willReturn('<link rel="stylesheet" href="">');
181 
182  $uiFactory->method('link')
183  ->willReturn($link);
184 
185  $uiRenderer = $this->getMockBuilder('ILIAS\UI\Renderer')
186  ->disableOriginalConstructor()
187  ->getMock();
188 
189  $uiRenderer->method('render')
190  ->with('<link rel="stylesheet" href="">')
191  ->willReturn('link');
192 
193  $utilHelper = $this->getMockBuilder('ilCertificateUtilHelper')
194  ->disableOriginalConstructor()
195  ->getMock();
196 
197  $utilHelper->method('getImagePath')
198  ->willReturn('/some/acutal/image/path/background.png');
199 
201  10,
202  $learningHistoryFactory,
203  $language,
204  $template,
205  $dic,
206  $userCertificateRepository,
207  $controller,
208  $certificateSettings,
209  $uiFactory,
210  $uiRenderer,
211  $utilHelper
212  );
213 
214  $expectedEntries = array(
216  'Certificate for link achieved.',
217  'Certificate for link achieved.',
218  '/some/acutal/image/path/background.png',
219  123456789,
220  200
221  ),
223  'Certificate for link achieved.',
224  'Certificate for link achieved.',
225  '/some/acutal/image/path/background.png',
226  987654321,
227  500
228  ),);
229 
230  $actualEntries = $provider->getEntries(123456789, 987654321);
231  $this->assertEquals($expectedEntries, $actualEntries);
232  }
$template

◆ testGetName()

ilCertificateLearningHistoryProviderTest::testGetName ( )

Definition at line 234 of file ilCertificateLearningHistoryProviderTest.php.

References $language, PHPMailer\PHPMailer\$provider, $template, and Sabre\Event\once().

235  {
236  $learningHistoryFactory = $this->getMockBuilder('ilLearningHistoryFactory')
237  ->disableOriginalConstructor()
238  ->getMock();
239 
240  $language = $this->getMockBuilder('ilLanguage')
241  ->disableOriginalConstructor()
242  ->getMock();
243 
244  $language
245  ->expects($this->once())
246  ->method('txt')
247  ->willReturn('Certificates');
248 
249  $dic = $this->getMockBuilder('\ILIAS\DI\Container')
250  ->disableOriginalConstructor()
251  ->getMock();
252 
253  $template = $this->getMockBuilder('ilTemplate')
254  ->disableOriginalConstructor()
255  ->getMock();
256 
257  $userCertificateRepository = $this->getMockBuilder('ilUserCertificateRepository')
258  ->disableOriginalConstructor()
259  ->getMock();
260 
261  $controller = $this->getMockBuilder('ilCtrl')
262  ->disableOriginalConstructor()
263  ->getMock();
264 
265  $certificateSettings = $this->getMockBuilder('ilSetting')
266  ->disableOriginalConstructor()
267  ->getMock();
268 
269  $certificateSettings->method('get')
270  ->willReturn(true);
271 
272  $uiFactory = $this->getMockBuilder('ILIAS\UI\Factory')
273  ->disableOriginalConstructor()
274  ->getMock();
275 
276  $uiRenderer = $this->getMockBuilder('ILIAS\UI\Renderer')
277  ->disableOriginalConstructor()
278  ->getMock();
279 
281  10,
282  $learningHistoryFactory,
283  $language,
284  $template,
285  $dic,
286  $userCertificateRepository,
287  $controller,
288  $certificateSettings,
289  $uiFactory,
290  $uiRenderer
291  );
292 
293  $this->assertEquals('Certificates', $provider->getName());
294  }
$template
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testIsActive()

ilCertificateLearningHistoryProviderTest::testIsActive ( )

Definition at line 5 of file ilCertificateLearningHistoryProviderTest.php.

References $language, PHPMailer\PHPMailer\$provider, and $template.

6  {
7  $learningHistoryFactory = $this->getMockBuilder('ilLearningHistoryFactory')
8  ->disableOriginalConstructor()
9  ->getMock();
10 
11  $language = $this->getMockBuilder('ilLanguage')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $dic = $this->getMockBuilder('\ILIAS\DI\Container')
16  ->disableOriginalConstructor()
17  ->getMock();
18 
19  $template = $this->getMockBuilder('ilTemplate')
20  ->disableOriginalConstructor()
21  ->getMock();
22 
23  $userCertificateRepository = $this->getMockBuilder('ilUserCertificateRepository')
24  ->disableOriginalConstructor()
25  ->getMock();
26 
27  $controller = $this->getMockBuilder('ilCtrl')
28  ->disableOriginalConstructor()
29  ->getMock();
30 
31  $certificateSettings = $this->getMockBuilder('ilSetting')
32  ->disableOriginalConstructor()
33  ->getMock();
34 
35  $certificateSettings->method('get')
36  ->willReturn(true);
37 
38  $uiFactory = $this->getMockBuilder('ILIAS\UI\Factory')
39  ->disableOriginalConstructor()
40  ->getMock();
41 
42  $uiRenderer = $this->getMockBuilder('ILIAS\UI\Renderer')
43  ->disableOriginalConstructor()
44  ->getMock();
45 
47  10,
48  $learningHistoryFactory,
49  $language,
50  $template,
51  $dic,
52  $userCertificateRepository,
53  $controller,
54  $certificateSettings,
55  $uiFactory,
56  $uiRenderer
57  );
58 
59  $this->assertTrue($provider->isActive());
60  }
$template

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