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

Public Member Functions

 testGetPlaceholderValues ()
 
 testGetPlaceholderValuesForPreview ()
 

Detailed Description

Member Function Documentation

◆ testGetPlaceholderValues()

ilDefaultPlaceholderValuesTest::testGetPlaceholderValues ( )

Definition at line 9 of file ilDefaultPlaceholderValuesTest.php.

References $input, $language, $result, and Sabre\Event\once().

10  {
11  $objectMock = $this->getMockBuilder('ilObjUser')
12  ->disableOriginalConstructor()
13  ->setMethods(
14  array(
15  'getLogin',
16  'getFullname',
17  'getFirstname',
18  'getLastname',
19  'getUTitle',
20  'getGender',
21  'getBirthday',
22  'getInstitution',
23  'getDepartment',
24  'getStreet',
25  'getCity',
26  'getZipcode',
27  'getCountry',
28  'getMatriculation'
29  )
30  )
31  ->getMock();
32 
33  $objectMock->expects($this->once())
34  ->method('getLogin')
35  ->willReturn('a_login');
36 
37  $objectMock->expects($this->once())
38  ->method('getFullname')
39  ->willReturn('Niels Theen');
40 
41  $objectMock->expects($this->once())
42  ->method('getFirstname')
43  ->willReturn('Niels');
44 
45  $objectMock->expects($this->once())
46  ->method('getLastname')
47  ->willReturn('Theen');
48 
49  $objectMock->expects($this->once())
50  ->method('getUTitle')
51  ->willReturn('');
52 
53  $objectMock->expects($this->once())
54  ->method('getGender')
55  ->willReturn('m');
56 
57  $objectMock->expects($this->once())
58  ->method('getBirthday')
59  ->willReturn('2018-10-10');
60 
61  $objectMock->expects($this->once())
62  ->method('getInstitution')
63  ->willReturn('');
64 
65  $objectMock->expects($this->once())
66  ->method('getDepartment')
67  ->willReturn('');
68 
69  $objectMock->expects($this->once())
70  ->method('getStreet')
71  ->willReturn('');
72 
73  $objectMock->expects($this->once())
74  ->method('getCity')
75  ->willReturn('');
76 
77  $objectMock->expects($this->once())
78  ->method('getZipcode')
79  ->willReturn('');
80 
81  $objectMock->expects($this->once())
82  ->method('getCountry')
83  ->willReturn('');
84 
85  $objectMock->expects($this->once())
86  ->method('getMatriculation')
87  ->willReturn('');
88 
89  $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
90  ->getMock();
91 
92  $objectHelper->expects($this->once())
93  ->method('getInstanceByObjId')
94  ->with(100)
95  ->willReturn($objectMock);
96 
97  $dateHelper = $this->getMockBuilder('ilCertificateDateHelper')
98  ->getMock();
99 
100  $dateHelper->expects($this->exactly(2))
101  ->method('formatDate')
102  ->willReturn('2018-09-10');
103 
104  $dateHelper->expects($this->once())
105  ->method('formatDateTime')
106  ->willReturn('2018-09-10 12:01:33');
107 
108  $language = $this->getMockBuilder('ilLanguage')
109  ->disableOriginalConstructor()
110  ->getMock();
111 
112  $language->method('txt')
113  ->willReturn('Something');
114 
115  $utilHelper = $this->getMockBuilder('ilCertificateUtilHelper')
116  ->getMock();
117 
118  $utilHelper->method('prepareFormOutput')
119  ->willReturnCallback(function ($input) {
120  return $input;
121  });
122 
123  $userDefinePlaceholderMock = $this->getMockBuilder('ilUserDefinedFieldsPlaceholderValues')
124  ->disableOriginalConstructor()
125  ->getMock();
126 
127  $userDefinePlaceholderMock->method('getPlaceholderValues')
128  ->willReturn(array());
129 
130  $userDefinePlaceholderMock->method('getPlaceholderValuesForPreview')
131  ->willReturn(array());
132 
133  $placeHolderObject = new ilDefaultPlaceholderValues(
134  $objectHelper,
135  $dateHelper,
136  1,
137  $language,
138  $utilHelper,
139  $userDefinePlaceholderMock,
140  1
141  );
142 
143  $result = $placeHolderObject->getPlaceholderValues(100, 200);
144 
145  $this->assertEquals(
146  array(
147  'USER_LOGIN' => 'a_login',
148  'USER_FULLNAME' => 'Niels Theen',
149  'USER_FIRSTNAME' => 'Niels',
150  'USER_LASTNAME' => 'Theen',
151  'USER_TITLE' => '',
152  'USER_SALUTATION' => 'Something',
153  'USER_BIRTHDAY' => '2018-09-10',
154  'USER_INSTITUTION' => '',
155  'USER_DEPARTMENT' => '',
156  'USER_STREET' => '',
157  'USER_CITY' => '',
158  'USER_ZIPCODE' => '',
159  'USER_COUNTRY' => '',
160  'USER_MATRICULATION' => '',
161  'DATE' => '',
162  'DATETIME' => '',
163  'DATE_COMPLETED' => '',
164  'DATETIME_COMPLETED' => '',
165  'DATE' => '2018-09-10',
166  'DATETIME' => '2018-09-10 12:01:33'
167  ),
168  $result
169  );
170  }
Collection of basic placeholder values that can be used.
$result
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
+ Here is the call graph for this function:

◆ testGetPlaceholderValuesForPreview()

ilDefaultPlaceholderValuesTest::testGetPlaceholderValuesForPreview ( )

Definition at line 172 of file ilDefaultPlaceholderValuesTest.php.

References $input, $language, and $result.

173  {
174  $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
175  ->getMock();
176 
177  $dateHelper = $this->getMockBuilder('ilCertificateDateHelper')
178  ->getMock();
179 
180  $dateHelper->method('formatDate')
181  ->willReturn('2018-09-09');
182 
183  $dateHelper->method('formatDateTime')
184  ->willReturn('2018-09-09 14:00:30');
185 
186  $language = $this->getMockBuilder('ilLanguage')
187  ->disableOriginalConstructor()
188  ->getMock();
189 
190  $language->method('txt')
191  ->willReturn('Something');
192 
193  $utilHelper = $this->getMockBuilder('ilCertificateUtilHelper')
194  ->getMock();
195 
196  $utilHelper->method('prepareFormOutput')
197  ->willReturnCallback(function ($input) {
198  return $input;
199  });
200 
201  $userDefinePlaceholderMock = $this->getMockBuilder('ilUserDefinedFieldsPlaceholderValues')
202  ->disableOriginalConstructor()
203  ->getMock();
204 
205  $userDefinePlaceholderMock->method('getPlaceholderValues')
206  ->willReturn(array());
207 
208  $userDefinePlaceholderMock->method('getPlaceholderValuesForPreview')
209  ->willReturn(array());
210 
211  $placeHolderObject = new ilDefaultPlaceholderValues(
212  $objectHelper,
213  $dateHelper,
214  1,
215  $language,
216  $utilHelper,
217  $userDefinePlaceholderMock,
218  1
219  );
220 
221  $result = $placeHolderObject->getPlaceholderValuesForPreview(
222  100,
223  10,
224  2
225  );
226 
227  $this->assertEquals(
228  array(
229  'USER_LOGIN' => 'Something',
230  'USER_FULLNAME' => 'Something',
231  'USER_FIRSTNAME' => 'Something',
232  'USER_LASTNAME' => 'Something',
233  'USER_TITLE' => 'Something',
234  'USER_SALUTATION' => 'Something',
235  'USER_BIRTHDAY' => '2018-09-09',
236  'USER_INSTITUTION' => 'Something',
237  'USER_DEPARTMENT' => 'Something',
238  'USER_STREET' => 'Something',
239  'USER_CITY' => 'Something',
240  'USER_ZIPCODE' => 'Something',
241  'USER_COUNTRY' => 'Something',
242  'USER_MATRICULATION' => 'Something',
243  'DATE' => '2018-09-09',
244  'DATETIME' => '2018-09-09 14:00:30',
245  'DATE_COMPLETED' => '2018-09-09',
246  'DATETIME_COMPLETED' => '2018-09-09 14:00:30'
247  ),
248  $result
249  );
250  }
Collection of basic placeholder values that can be used.
$result

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