ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilDefaultPlaceholderValuesTest Class Reference
+ Inheritance diagram for ilDefaultPlaceholderValuesTest:
+ Collaboration diagram for ilDefaultPlaceholderValuesTest:

Public Member Functions

 testGetPlaceholderValues ()
 
 testGetPlaceholderValuesForPreview ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilCertificateBaseTestCase
 setUp ()
 
 setGlobalVariable (string $name, $value)
 

Detailed Description

Member Function Documentation

◆ testGetPlaceholderValues()

ilDefaultPlaceholderValuesTest::testGetPlaceholderValues ( )

Definition at line 26 of file ilDefaultPlaceholderValuesTest.php.

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

◆ testGetPlaceholderValuesForPreview()

ilDefaultPlaceholderValuesTest::testGetPlaceholderValuesForPreview ( )

Definition at line 189 of file ilDefaultPlaceholderValuesTest.php.

189  : void
190  {
191  $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
192  ->getMock();
193 
194  $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
195  ->getMock();
196 
197  $dateHelper->method('formatDate')
198  ->willReturn('2018-09-09');
199 
200  $dateHelper->method('formatDateTime')
201  ->willReturn('2018-09-09 14:00:30');
202 
203  $language = $this->getMockBuilder(ilLanguage::class)
204  ->disableOriginalConstructor()
205  ->getMock();
206 
207  $language->method('txt')
208  ->willReturn('Something');
209 
210  $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
211  ->disableOriginalConstructor()
212  ->getMock();
213 
214  $utilHelper->method('prepareFormOutput')
215  ->willReturnCallback(function ($input) {
216  return $input;
217  });
218 
219  $userDefinePlaceholderMock = $this->getMockBuilder(ilUserDefinedFieldsPlaceholderValues::class)
220  ->disableOriginalConstructor()
221  ->getMock();
222 
223  $userDefinePlaceholderMock->method('getPlaceholderValues')
224  ->willReturn([]);
225 
226  $userDefinePlaceholderMock->method('getPlaceholderValuesForPreview')
227  ->willReturn([]);
228 
229  $placeHolderObject = new ilDefaultPlaceholderValues(
230  $objectHelper,
231  $dateHelper,
232  1,
233  $language,
234  $utilHelper,
235  $userDefinePlaceholderMock,
236  1
237  );
238 
239  $result = $placeHolderObject->getPlaceholderValuesForPreview(
240  100,
241  10
242  );
243 
244  $this->assertSame(
245  [
246  'USER_LOGIN' => 'Something',
247  'USER_FULLNAME' => 'Something',
248  'USER_FIRSTNAME' => 'Something',
249  'USER_LASTNAME' => 'Something',
250  'USER_TITLE' => 'Something',
251  'USER_SALUTATION' => 'Something',
252  'USER_BIRTHDAY' => '2018-09-09',
253  'USER_INSTITUTION' => 'Something',
254  'USER_DEPARTMENT' => 'Something',
255  'USER_STREET' => 'Something',
256  'USER_CITY' => 'Something',
257  'USER_ZIPCODE' => 'Something',
258  'USER_COUNTRY' => 'Something',
259  'USER_MATRICULATION' => 'Something',
260  'DATE' => '2018-09-09',
261  'DATETIME' => '2018-09-09 14:00:30',
262  'DATE_COMPLETED' => '2018-09-09',
263  'DATETIME_COMPLETED' => '2018-09-09 14:00:30'
264  ],
265  $result
266  );
267  }
Collection of basic placeholder values that can be used.

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