ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
DateTimeTest.php
Go to the documentation of this file.
1<?php
2
3
4require_once 'testDataFileIterator.php';
5
7{
8
9 public function setUp()
10 {
11 if (!defined('PHPEXCEL_ROOT'))
12 {
13 define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
14 }
15 require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
16
18 }
19
23 public function testDATE()
24 {
25 $args = func_get_args();
26 $expectedResult = array_pop($args);
27 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATE'),$args);
28 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
29 }
30
31 public function providerDATE()
32 {
33 return new testDataFileIterator('rawTestData/Calculation/DateTime/DATE.data');
34 }
35
36 public function testDATEtoPHP()
37 {
41 $this->assertEquals(1327968000, $result, NULL, 1E-8);
42 }
43
44 public function testDATEtoPHPObject()
45 {
49 // Must return an object...
50 $this->assertTrue(is_object($result));
51 // ... of the correct type
52 $this->assertTrue(is_a($result,'DateTime'));
53 // ... with the correct value
54 $this->assertEquals($result->format('d-M-Y'),'31-Jan-2012');
55 }
56
57 public function testDATEwith1904Calendar()
58 {
62 $this->assertEquals($result,5428);
63 }
64
66 {
70 $this->assertEquals($result,'#NUM!');
71 }
72
76 public function testDATEVALUE()
77 {
78 $args = func_get_args();
79 $expectedResult = array_pop($args);
80 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEVALUE'),$args);
81 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
82 }
83
84 public function providerDATEVALUE()
85 {
86 return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEVALUE.data');
87 }
88
89 public function testDATEVALUEtoPHP()
90 {
94 $this->assertEquals(1327968000, $result, NULL, 1E-8);
95 }
96
97 public function testDATEVALUEtoPHPObject()
98 {
102 // Must return an object...
103 $this->assertTrue(is_object($result));
104 // ... of the correct type
105 $this->assertTrue(is_a($result,'DateTime'));
106 // ... with the correct value
107 $this->assertEquals($result->format('d-M-Y'),'31-Jan-2012');
108 }
109
113 public function testYEAR()
114 {
115 $args = func_get_args();
116 $expectedResult = array_pop($args);
117 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEAR'),$args);
118 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
119 }
120
121 public function providerYEAR()
122 {
123 return new testDataFileIterator('rawTestData/Calculation/DateTime/YEAR.data');
124 }
125
129 public function testMONTH()
130 {
131 $args = func_get_args();
132 $expectedResult = array_pop($args);
133 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MONTHOFYEAR'),$args);
134 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
135 }
136
137 public function providerMONTH()
138 {
139 return new testDataFileIterator('rawTestData/Calculation/DateTime/MONTH.data');
140 }
141
145 public function testWEEKNUM()
146 {
147 $args = func_get_args();
148 $expectedResult = array_pop($args);
149 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WEEKOFYEAR'),$args);
150 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
151 }
152
153 public function providerWEEKNUM()
154 {
155 return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKNUM.data');
156 }
157
161 public function testWEEKDAY()
162 {
163 $args = func_get_args();
164 $expectedResult = array_pop($args);
165 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFWEEK'),$args);
166 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
167 }
168
169 public function providerWEEKDAY()
170 {
171 return new testDataFileIterator('rawTestData/Calculation/DateTime/WEEKDAY.data');
172 }
173
177 public function testDAY()
178 {
179 $args = func_get_args();
180 $expectedResult = array_pop($args);
181 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYOFMONTH'),$args);
182 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
183 }
184
185 public function providerDAY()
186 {
187 return new testDataFileIterator('rawTestData/Calculation/DateTime/DAY.data');
188 }
189
193 public function testTIME()
194 {
195 $args = func_get_args();
196 $expectedResult = array_pop($args);
197 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIME'),$args);
198 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
199 }
200
201 public function providerTIME()
202 {
203 return new testDataFileIterator('rawTestData/Calculation/DateTime/TIME.data');
204 }
205
206 public function testTIMEtoPHP()
207 {
211 $this->assertEquals(27020, $result, NULL, 1E-8);
212 }
213
214 public function testTIMEtoPHPObject()
215 {
219 // Must return an object...
220 $this->assertTrue(is_object($result));
221 // ... of the correct type
222 $this->assertTrue(is_a($result,'DateTime'));
223 // ... with the correct value
224 $this->assertEquals($result->format('H:i:s'),'07:30:20');
225 }
226
230 public function testTIMEVALUE()
231 {
232 $args = func_get_args();
233 $expectedResult = array_pop($args);
234 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','TIMEVALUE'),$args);
235 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
236 }
237
238 public function providerTIMEVALUE()
239 {
240 return new testDataFileIterator('rawTestData/Calculation/DateTime/TIMEVALUE.data');
241 }
242
243 public function testTIMEVALUEtoPHP()
244 {
248 $this->assertEquals(23420, $result, NULL, 1E-8);
249 }
250
251 public function testTIMEVALUEtoPHPObject()
252 {
256 // Must return an object...
257 $this->assertTrue(is_object($result));
258 // ... of the correct type
259 $this->assertTrue(is_a($result,'DateTime'));
260 // ... with the correct value
261 $this->assertEquals($result->format('H:i:s'),'07:30:20');
262 }
263
267 public function testHOUR()
268 {
269 $args = func_get_args();
270 $expectedResult = array_pop($args);
271 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','HOUROFDAY'),$args);
272 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
273 }
274
275 public function providerHOUR()
276 {
277 return new testDataFileIterator('rawTestData/Calculation/DateTime/HOUR.data');
278 }
279
283 public function testMINUTE()
284 {
285 $args = func_get_args();
286 $expectedResult = array_pop($args);
287 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','MINUTEOFHOUR'),$args);
288 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
289 }
290
291 public function providerMINUTE()
292 {
293 return new testDataFileIterator('rawTestData/Calculation/DateTime/MINUTE.data');
294 }
295
299 public function testSECOND()
300 {
301 $args = func_get_args();
302 $expectedResult = array_pop($args);
303 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','SECONDOFMINUTE'),$args);
304 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
305 }
306
307 public function providerSECOND()
308 {
309 return new testDataFileIterator('rawTestData/Calculation/DateTime/SECOND.data');
310 }
311
315 public function testNETWORKDAYS()
316 {
317 $args = func_get_args();
318 $expectedResult = array_pop($args);
319 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','NETWORKDAYS'),$args);
320 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
321 }
322
323 public function providerNETWORKDAYS()
324 {
325 return new testDataFileIterator('rawTestData/Calculation/DateTime/NETWORKDAYS.data');
326 }
327
331 public function testWORKDAY()
332 {
333 $args = func_get_args();
334 $expectedResult = array_pop($args);
335 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','WORKDAY'),$args);
336 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
337 }
338
339 public function providerWORKDAY()
340 {
341 return new testDataFileIterator('rawTestData/Calculation/DateTime/WORKDAY.data');
342 }
343
347 public function testEDATE()
348 {
349 $args = func_get_args();
350 $expectedResult = array_pop($args);
351 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EDATE'),$args);
352 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
353 }
354
355 public function providerEDATE()
356 {
357 return new testDataFileIterator('rawTestData/Calculation/DateTime/EDATE.data');
358 }
359
360 public function testEDATEtoPHP()
361 {
365 $this->assertEquals(1324857600, $result, NULL, 1E-8);
366 }
367
368 public function testEDATEtoPHPObject()
369 {
373 // Must return an object...
374 $this->assertTrue(is_object($result));
375 // ... of the correct type
376 $this->assertTrue(is_a($result,'DateTime'));
377 // ... with the correct value
378 $this->assertEquals($result->format('d-M-Y'),'26-Dec-2011');
379 }
380
384 public function testEOMONTH()
385 {
386 $args = func_get_args();
387 $expectedResult = array_pop($args);
388 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','EOMONTH'),$args);
389 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
390 }
391
392 public function providerEOMONTH()
393 {
394 return new testDataFileIterator('rawTestData/Calculation/DateTime/EOMONTH.data');
395 }
396
397 public function testEOMONTHtoPHP()
398 {
402 $this->assertEquals(1325289600, $result, NULL, 1E-8);
403 }
404
405 public function testEOMONTHtoPHPObject()
406 {
410 // Must return an object...
411 $this->assertTrue(is_object($result));
412 // ... of the correct type
413 $this->assertTrue(is_a($result,'DateTime'));
414 // ... with the correct value
415 $this->assertEquals($result->format('d-M-Y'),'31-Dec-2011');
416 }
417
421 public function testDATEDIF()
422 {
423 $args = func_get_args();
424 $expectedResult = array_pop($args);
425 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DATEDIF'),$args);
426 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
427 }
428
429 public function providerDATEDIF()
430 {
431 return new testDataFileIterator('rawTestData/Calculation/DateTime/DATEDIF.data');
432 }
433
437 public function testDAYS360()
438 {
439 $args = func_get_args();
440 $expectedResult = array_pop($args);
441 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','DAYS360'),$args);
442 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
443 }
444
445 public function providerDAYS360()
446 {
447 return new testDataFileIterator('rawTestData/Calculation/DateTime/DAYS360.data');
448 }
449
453 public function testYEARFRAC()
454 {
455 $args = func_get_args();
456 $expectedResult = array_pop($args);
457 $result = call_user_func_array(array('PHPExcel_Calculation_DateTime','YEARFRAC'),$args);
458 $this->assertEquals($expectedResult, $result, NULL, 1E-8);
459 }
460
461 public function providerYEARFRAC()
462 {
463 return new testDataFileIterator('rawTestData/Calculation/DateTime/YEARFRAC.data');
464 }
465
466}
$result
An exception for terminatinating execution or to throw for unit testing.
testDATEDIF()
@dataProvider providerDATEDIF
testDATEVALUE()
@dataProvider providerDATEVALUE
testDAYS360()
@dataProvider providerDAYS360
testMONTH()
@dataProvider providerMONTH
testDATEVALUEtoPHPObject()
testSECOND()
@dataProvider providerSECOND
testDATEwith1904Calendar()
testTIME()
@dataProvider providerTIME
testYEARFRAC()
@dataProvider providerYEARFRAC
testDAY()
@dataProvider providerDAY
testNETWORKDAYS()
@dataProvider providerNETWORKDAYS
testWORKDAY()
@dataProvider providerWORKDAY
testDATEwith1904CalendarError()
testWEEKDAY()
@dataProvider providerWEEKDAY
testWEEKNUM()
@dataProvider providerWEEKNUM
testEOMONTH()
@dataProvider providerEOMONTH
testTIMEVALUE()
@dataProvider providerTIMEVALUE
testTIMEVALUEtoPHPObject()
testEDATE()
@dataProvider providerEDATE
testDATE()
@dataProvider providerDATE
testHOUR()
@dataProvider providerHOUR
testYEAR()
@dataProvider providerYEAR
testMINUTE()
@dataProvider providerMINUTE
static TIME($hour=0, $minute=0, $second=0)
Definition: DateTime.php:386
static EOMONTH($dateValue=1, $adjustmentMonths=0)
EOMONTH.
Definition: DateTime.php:1455
static DATEVALUE($dateValue=1)
Definition: DateTime.php:481
static DATE($year=0, $month=1, $day=1)
Definition: DateTime.php:292
static TIMEVALUE($timeValue)
Definition: DateTime.php:583
static EDATE($dateValue=1, $adjustmentMonths=0)
EDATE.
Definition: DateTime.php:1410
static setReturnDateType($returnDateType)
Definition: Functions.php:155
const COMPATIBILITY_EXCEL
constants
Definition: Functions.php:62
static setCompatibilityMode($compatibilityMode)
Definition: Functions.php:116
static setExcelCalendar($baseDate)
Set the Excel calendar (Windows 1900 or Mac 1904)
Definition: Date.php:91
const CALENDAR_MAC_1904
Definition: Date.php:41
const CALENDAR_WINDOWS_1900
constants
Definition: Date.php:40
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27