25 : void
26 {
27 $objectMock = $this->getMockBuilder(ilObjUser::class)
28 ->disableOriginalConstructor()
29 ->onlyMethods(
30 [
31 'getLogin',
32 'getFullname',
33 'getFirstname',
34 'getLastname',
35 'getUTitle',
36 'getGender',
37 'getBirthday',
38 'getInstitution',
39 'getDepartment',
40 'getStreet',
41 'getCity',
42 'getZipcode',
43 'getCountry',
44 'getMatriculation'
45 ]
46 )
47 ->getMock();
48
49 $objectMock->expects($this->once())
50 ->method('getLogin')
51 ->willReturn('a_login');
52
53 $objectMock->expects($this->once())
54 ->method('getFullname')
55 ->willReturn('Niels Theen');
56
57 $objectMock->expects($this->once())
58 ->method('getFirstname')
59 ->willReturn('Niels');
60
61 $objectMock->expects($this->once())
62 ->method('getLastname')
63 ->willReturn('Theen');
64
65 $objectMock->expects($this->once())
66 ->method('getUTitle')
67 ->willReturn('');
68
69 $objectMock->expects($this->once())
70 ->method('getGender')
71 ->willReturn('m');
72
73 $objectMock->expects($this->once())
74 ->method('getBirthday')
75 ->willReturn('2018-10-10');
76
77 $objectMock->expects($this->once())
78 ->method('getInstitution')
79 ->willReturn('');
80
81 $objectMock->expects($this->once())
82 ->method('getDepartment')
83 ->willReturn('');
84
85 $objectMock->expects($this->once())
86 ->method('getStreet')
87 ->willReturn('');
88
89 $objectMock->expects($this->once())
90 ->method('getCity')
91 ->willReturn('');
92
93 $objectMock->expects($this->once())
94 ->method('getZipcode')
95 ->willReturn('');
96
97 $objectMock->expects($this->once())
98 ->method('getCountry')
99 ->willReturn('');
100
101 $objectMock->expects($this->once())
102 ->method('getMatriculation')
103 ->willReturn('');
104
105 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
106 ->getMock();
107
108 $objectHelper->expects($this->once())
109 ->method('getInstanceByObjId')
110 ->with(100)
111 ->willReturn($objectMock);
112
113 $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
114 ->getMock();
115
116 $dateHelper->expects($this->exactly(2))
117 ->method('formatDate')
118 ->willReturn('2018-09-10');
119
120 $dateHelper->expects($this->once())
121 ->method('formatDateTime')
122 ->willReturn('2018-09-10 12:01:33');
123
124 $language = $this->getMockBuilder(ilLanguage::class)
125 ->disableOriginalConstructor()
126 ->getMock();
127
128 $language->method('txt')
129 ->willReturn('Something');
130
131 $profile = $this->getMockBuilder(Profile::class)
132 ->disableOriginalConstructor()
133 ->getMock();
134
135 $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
136 ->disableOriginalConstructor()
137 ->getMock();
138
139 $utilHelper->method('prepareFormOutput')
140 ->willReturnCallback(function ($input) {
141 return $input;
142 });
143
144 $userDefinePlaceholderMock = $this->getMockBuilder(ilUserDefinedFieldsPlaceholderValues::class)
145 ->disableOriginalConstructor()
146 ->getMock();
147
148 $userDefinePlaceholderMock->method('getPlaceholderValues')
149 ->willReturn([]);
150
151 $userDefinePlaceholderMock->method('getPlaceholderValuesForPreview')
152 ->willReturn([]);
153
154 $uuid_factory_mock = $this->getMockBuilder(
ILIAS\Data\UUID\Factory::class)
155 ->getMock();
156 $uuid_factory_mock->method('uuid4AsString')->willReturn('randomUniqueString');
157
159 $objectHelper,
160 $dateHelper,
161 3,
162 $language,
163 $profile,
164 $utilHelper,
165 $userDefinePlaceholderMock,
166 $uuid_factory_mock,
167 2
168 );
169 $placeHolderObject->setUserLanguage($language);
170
171 $result = $placeHolderObject->getPlaceholderValues(100, 200);
172
173 $this->assertEquals(
174 [
175 'CERTIFICATE_ID' => '',
176 'USER_LOGIN' => 'a_login',
177 'USER_FULLNAME' => 'Niels Theen',
178 'USER_FIRSTNAME' => 'Niels',
179 'USER_LASTNAME' => 'Theen',
180 'USER_TITLE' => '',
181 'USER_SALUTATION' => 'Something',
182 'USER_BIRTHDAY' => '2018-09-10',
183 'USER_INSTITUTION' => '',
184 'USER_DEPARTMENT' => '',
185 'USER_STREET' => '',
186 'USER_CITY' => '',
187 'USER_ZIPCODE' => '',
188 'USER_COUNTRY' => '',
189 'USER_MATRICULATION' => '',
190 'DATE_COMPLETED' => '',
191 'DATETIME_COMPLETED' => '',
192 'DATE' => '2018-09-10',
193 'DATETIME' => '2018-09-10 12:01:33'
194 ],
195 $result
196 );
197 }
Collection of basic placeholder values that can be used.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.