ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
- Protected Attributes inherited from ilCertificateBaseTestCase
Container $dic
 

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  $uuid_factory_mock = $this->getMockBuilder(ILIAS\Data\UUID\Factory::class)
152  ->getMock();
153  $uuid_factory_mock->method('uuid4AsString')->willReturn('randomUniqueString');
154 
155  $placeHolderObject = new ilDefaultPlaceholderValues(
156  $objectHelper,
157  $dateHelper,
158  1,
159  $language,
160  $utilHelper,
161  $userDefinePlaceholderMock,
162  $uuid_factory_mock,
163  1
164  );
165  $placeHolderObject->setUserLanguage($language);
166 
167  $result = $placeHolderObject->getPlaceholderValues(100, 200);
168 
169  $this->assertEquals(
170  [
171  'CERTIFICATE_ID' => '',
172  'USER_LOGIN' => 'a_login',
173  'USER_FULLNAME' => 'Niels Theen',
174  'USER_FIRSTNAME' => 'Niels',
175  'USER_LASTNAME' => 'Theen',
176  'USER_TITLE' => '',
177  'USER_SALUTATION' => 'Something',
178  'USER_BIRTHDAY' => '2018-09-10',
179  'USER_INSTITUTION' => '',
180  'USER_DEPARTMENT' => '',
181  'USER_STREET' => '',
182  'USER_CITY' => '',
183  'USER_ZIPCODE' => '',
184  'USER_COUNTRY' => '',
185  'USER_MATRICULATION' => '',
186  'DATE_COMPLETED' => '',
187  'DATETIME_COMPLETED' => '',
188  'DATE' => '2018-09-10',
189  'DATETIME' => '2018-09-10 12:01:33'
190  ],
191  $result
192  );
193  }
Interface Observer Contains several chained tasks and infos about them.

◆ testGetPlaceholderValuesForPreview()

ilDefaultPlaceholderValuesTest::testGetPlaceholderValuesForPreview ( )

Definition at line 195 of file ilDefaultPlaceholderValuesTest.php.

195  : void
196  {
197  $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
198  ->getMock();
199 
200  $dateHelper = $this->getMockBuilder(ilCertificateDateHelper::class)
201  ->getMock();
202 
203  $dateHelper->method('formatDate')
204  ->willReturn('2018-09-09');
205 
206  $dateHelper->method('formatDateTime')
207  ->willReturn('2018-09-09 14:00:30');
208 
209  $language = $this->getMockBuilder(ilLanguage::class)
210  ->disableOriginalConstructor()
211  ->getMock();
212 
213  $language->method('txt')
214  ->willReturn('Something');
215 
216  $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
217  ->disableOriginalConstructor()
218  ->getMock();
219 
220  $utilHelper->method('prepareFormOutput')
221  ->willReturnCallback(function ($input) {
222  return $input;
223  });
224 
225  $userDefinePlaceholderMock = $this->getMockBuilder(ilUserDefinedFieldsPlaceholderValues::class)
226  ->disableOriginalConstructor()
227  ->getMock();
228 
229  $userDefinePlaceholderMock->method('getPlaceholderValues')
230  ->willReturn([]);
231 
232  $userDefinePlaceholderMock->method('getPlaceholderValuesForPreview')
233  ->willReturn([]);
234 
235  $uuid_factory_mock = $this->getMockBuilder(ILIAS\Data\UUID\Factory::class)
236  ->getMock();
237  $uuid_factory_mock->method('uuid4AsString')->willReturn('randomUniqueString');
238 
239  $placeHolderObject = new ilDefaultPlaceholderValues(
240  $objectHelper,
241  $dateHelper,
242  1,
243  $language,
244  $utilHelper,
245  $userDefinePlaceholderMock,
246  $uuid_factory_mock,
247  1
248  );
249 
250  $result = $placeHolderObject->getPlaceholderValuesForPreview(
251  100,
252  10
253  );
254 
255  $this->assertSame(
256  [
257  'CERTIFICATE_ID' => 'randomUniqueString',
258  'USER_LOGIN' => 'Something',
259  'USER_FULLNAME' => 'Something',
260  'USER_FIRSTNAME' => 'Something',
261  'USER_LASTNAME' => 'Something',
262  'USER_TITLE' => 'Something',
263  'USER_SALUTATION' => 'Something',
264  'USER_BIRTHDAY' => '2018-09-09',
265  'USER_INSTITUTION' => 'Something',
266  'USER_DEPARTMENT' => 'Something',
267  'USER_STREET' => 'Something',
268  'USER_CITY' => 'Something',
269  'USER_ZIPCODE' => 'Something',
270  'USER_COUNTRY' => 'Something',
271  'USER_MATRICULATION' => 'Something',
272  'DATE' => '2018-09-09',
273  'DATETIME' => '2018-09-09 14:00:30',
274  'DATE_COMPLETED' => '2018-09-09',
275  'DATETIME_COMPLETED' => '2018-09-09 14:00:30'
276  ],
277  $result
278  );
279  }
Interface Observer Contains several chained tasks and infos about them.

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