-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic_test.phpt
79 lines (73 loc) · 2.32 KB
/
basic_test.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
--TEST--
Test basic calculation test of the data model
--FILE--
<?php
require_once('DataModel.php');
$model = new DateModel();
echo "testing \$model->parse_date()\n";
var_dump($model->parse_date('April 26, 2017'));
var_dump($model->parse_date('today'));
var_dump($model->parse_date('2009-22-12'));
var_dump($model->parse_date('April 26, 2017 12:00'));
var_dump($model->parse_date('2009-22-12 12:00'));
var_dump($model->parse_date('r2-d2'));
var_dump($model->parse_date(''));
var_dump($model->parse_date(array()));
echo "\n----------------\n";
echo "testing \$model->calculate_difference()\n";
var_dump($model->calculate_difference('April 26, 2017', 'April 26, 2016'));
var_dump($model->calculate_difference('today', 'August 6th, 2015'));
var_dump($model->calculate_difference('2009-22-12', 'Feb. 26, 2017 11:00'));
var_dump($model->calculate_difference('April 26, 2017 12:00'));
var_dump($model->calculate_difference('2009-22-12 12:00'));
var_dump($model->calculate_difference('r2-d2','2009-22-12 12:00'));
var_dump($model->calculate_difference(''));
var_dump($model->calculate_difference(array()));
echo "Done\n";
?>
--EXPECTF--
testing model->parse_date()
array(1) {
["date"]=>
string(19) "2017-04-26 00:00:00"
}
array(1) {
["date"]=>
string(19) "2017-01-29 00:00:00"
}
array(1) {
["date"]=>
string(19) "2009-12-22 00:00:00"
}
array(1) {
["date"]=>
string(19) "2017-04-26 12:00:00"
}
array(1) {
["date"]=>
string(19) "2009-12-22 12:00:00"
}
array(1) {
["error"]=>
string(82) "<ul><li>Missing the year</li><li>Missing a month</li><li>Missing the day</li></ul>"
}
array(1) {
["error"]=>
string(82) "<ul><li>Missing the year</li><li>Missing a month</li><li>Missing the day</li></ul>"
}
array(1) {
["error"]=>
string(82) "<ul><li>Missing the year</li><li>Missing a month</li><li>Missing the day</li></ul>"
}
----------------
testing model->calculate_difference()
string(50) "<span class="date_diffs"> is 365 days from </span>"
string(50) "<span class="date_diffs"> is 542 days from </span>"
string(51) "<span class="date_diffs"> is 2623 days from </span>"
string(38) "<span class="date_diffs"> </span>"
string(38) "<span class="date_diffs"> </span>"
string(38) "<span class="date_diffs"> </span>"
string(38) "<span class="date_diffs"> </span>"
string(38) "<span class="date_diffs"> </span>"
----------------
Done