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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
<?php
namespace bdrem;
class EventTest extends \PHPUnit_Framework_TestCase
{
public function testIsWithinSameDaySameYear()
{
$event = new Event('Amy', 'birthday', '1995-02-24');
$this->assertTrue($event->isWithin('1995-02-24', 0, 0));
$this->assertTrue($event->isWithin('1995-02-24', 3, 7));
}
public function testIsWithinSameDayDifferentYear()
{
$event = new Event('Amy', 'birthday', '1995-02-24');
$this->assertTrue($event->isWithin('2019-02-24', 0, 0));
$this->assertTrue($event->isWithin('1996-02-24', 3, 7));
}
public function testIsWithinOneDayAfterSameYear()
{
$event = new Event('Amy', 'birthday', '1995-02-24');
$this->assertFalse($event->isWithin('1995-02-23', 0, 0));
$this->assertTrue($event->isWithin('1995-02-23', 3, 7));
}
public function testIsWithinOneDayBeforeSameYear()
{
$event = new Event('Amy', 'birthday', '1995-02-24');
$this->assertFalse($event->isWithin('1995-02-25', 0, 0));
$this->assertTrue($event->isWithin('1995-02-25', 3, 7));
}
public function testIsWithinOneDayBeforeDifferentYear()
{
$event = new Event('Amy', 'birthday', '1995-02-24');
$this->assertFalse($event->isWithin('1999-02-25', 0, 0));
$this->assertTrue($event->isWithin('1990-02-25', 3, 7));
}
public function testIsWithinThreeDaysBeforeSameYear()
{
$event = new Event('Amy', 'birthday', '1995-02-24');
$this->assertFalse($event->isWithin('1999-02-27', 0, 0));
$this->assertFalse($event->isWithin('1999-02-27', 1, 0));
$this->assertFalse($event->isWithin('1999-02-27', 2, 0));
$this->assertTrue( $event->isWithin('1990-02-27', 3, 0));
$this->assertFalse($event->isWithin('1999-02-27', 0, 3));
}
public function testIsWithinYearOverflowAfter()
{
$event = new Event('Amy', 'birthday', '1995-01-01');
$this->assertTrue($event->isWithin('2019-12-31', 0, 1));
$this->assertFalse($event->isWithin('1996-12-30', 0, 1));
}
public function testIsWithinYearOverflowBefore()
{
$event = new Event('Amy', 'birthday', '1995-12-30');
$this->assertTrue($event->isWithin('2019-01-02', 3, 0));
$this->assertFalse($event->isWithin('1996-01-02', 2, 0));
$this->assertTrue($event->isWithin('1996-01-01', 2, 0));
}
public function testCompareDifferentMonths()
{
$this->assertLessThan(
0,
Event::compare(
new Event('Amy', 'birthday', '2013-05-10'),
new Event('Bob', 'birthday', '2013-06-10')
)
);
$this->assertGreaterThan(
0,
Event::compare(
new Event('Amy', 'birthday', '2013-10-10'),
new Event('Bob', 'birthday', '2013-08-10')
)
);
}
public function testCompareDifferentMonthsYearOverflow()
{
$this->assertGreaterThan(
0,
Event::compare(
new Event('Amy', 'birthday', '2013-01-10'),
new Event('Bob', 'birthday', '2013-12-10')
)
);
$this->assertLessThan(
0,
Event::compare(
new Event('Amy', 'birthday', '2013-12-10'),
new Event('Bob', 'birthday', '2013-02-10')
)
);
}
public function testCompareDifferentDays()
{
$this->assertLessThan(
0,
Event::compare(
new Event('Amy', 'birthday', '1950-05-10'),
new Event('Bob', 'birthday', '2013-05-11')
)
);
$this->assertGreaterThan(
0,
Event::compare(
new Event('Amy', 'birthday', '2013-10-20'),
new Event('Bob', 'birthday', '1992-10-02')
)
);
}
public function testCompareSameDay()
{
$this->assertLessThan(
0,
Event::compare(
new Event('Amy', 'birthday', '1950-05-10'),
new Event('Bob', 'birthday', '2013-05-10')
)
);
$this->assertGreaterThan(
0,
Event::compare(
new Event('Bob', 'birthday', '1992-10-02'),
new Event('Amy', 'birthday', '2013-10-02')
)
);
}
}
?>
|