ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilCoursePlaceholderValuesTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
9 public function testGetPlaceholderValues()
10 {
11 $defaultPlaceholderValues = $this->getMockBuilder('ilDefaultPlaceholderValues')
12 ->disableOriginalConstructor()
13 ->getMock();
14
15 $defaultPlaceholderValues->method('getPlaceholderValues')
16 ->willReturn(array());
17
18 $language = $this->getMockBuilder('ilLanguage')
19 ->disableOriginalConstructor()
20 ->getMock();
21
22 $language->method('txt')
23 ->willReturn('Something');
24
25 $objectMock = $this->getMockBuilder('ilObject')
26 ->disableOriginalConstructor()
27 ->getMock();
28
29 $objectMock->method('getTitle')
30 ->willReturn('Some Title');
31
32 $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
33 ->getMock();
34
35 $objectHelper->method('getInstanceByObjId')
36 ->willReturn($objectMock);
37
38 $participantsHelper = $this->getMockBuilder('ilCertificateParticipantsHelper')
39 ->getMock();
40
41 $participantsHelper->method('getDateTimeOfPassed')
42 ->willReturn('2018-09-10');
43
44 $ilUtilHelper = $this->getMockBuilder('ilCertificateUtilHelper')
45 ->getMock();
46
47 $ilUtilHelper->method('prepareFormOutput')
48 ->willReturn('Some Title');
49
50 $ilDateHelper = $this->getMockBuilder('ilCertificateDateHelper')
51 ->getMock();
52
53 $ilDateHelper->method('formatDate')
54 ->willReturn('2018-09-10');
55
56 $ilDateHelper->method('formatDateTime')
57 ->willReturn('2018-09-10 10:32:00');
58
59 $valuesObject = new ilCoursePlaceholderValues(
60 $defaultPlaceholderValues,
61 $language,
62 $objectHelper,
63 $participantsHelper,
64 $ilUtilHelper,
65 $ilDateHelper
66 );
67
68 $placeholderValues = $valuesObject->getPlaceholderValues(100, 200);
69
70 $this->assertEquals(
71 array(
72 'COURSE_TITLE' => 'Some Title',
73 'DATE_COMPLETED' => '2018-09-10',
74 'DATETIME_COMPLETED' => '2018-09-10 10:32:00'
75 ),
76 $placeholderValues
77 );
78 }
79
81 {
82 $defaultPlaceholderValues = $this->getMockBuilder('ilDefaultPlaceholderValues')
83 ->disableOriginalConstructor()
84 ->getMock();
85
86 $defaultPlaceholderValues->method('getPlaceholderValuesForPreview')
87 ->willReturn(
88 array(
89 'SOME_PLACEHOLDER' => 'ANYTHING',
90 'SOME_OTHER_PLACEHOLDER' => '2018-09-10',
91 )
92 );
93
94 $language = $this->getMockBuilder('ilLanguage')
95 ->disableOriginalConstructor()
96 ->getMock();
97
98 $language->method('txt')
99 ->willReturn('Something');
100
101 $objectMock = $this->getMockBuilder('ilObject')
102 ->disableOriginalConstructor()
103 ->getMock();
104
105 $objectMock->method('getTitle')
106 ->willReturn('SomeTitle');
107
108 $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
109 ->getMock();
110
111 $objectHelper->method('getInstanceByObjId')
112 ->willReturn($objectMock);
113
114 $participantsHelper = $this->getMockBuilder('ilCertificateParticipantsHelper')
115 ->getMock();
116
117 $utilHelper = $this->getMockBuilder('ilCertificateUtilHelper')
118 ->getMock();
119
120 $utilHelper->method('prepareFormOutput')
121 ->willReturnCallback(function ($input) {
122 return $input;
123 });
124
125 $valuesObject = new ilCoursePlaceholderValues(
126 $defaultPlaceholderValues,
127 $language,
128 $objectHelper,
129 $participantsHelper,
130 $utilHelper
131 );
132
133 $placeholderValues = $valuesObject->getPlaceholderValuesForPreview(100, 10);
134
135 $this->assertEquals(
136 array(
137 'SOME_PLACEHOLDER' => 'ANYTHING',
138 'SOME_OTHER_PLACEHOLDER' => '2018-09-10',
139 'COURSE_TITLE' => 'SomeTitle'
140 ),
141 $placeholderValues
142 );
143 }
144}
An exception for terminatinating execution or to throw for unit testing.
Class ilCertificateBaseTestCase.