| 1 |
lars |
1 |
<?php
|
|
|
2 |
// $Id: month_weeks_test.php 269074 2008-11-15 21:21:42Z quipo $
|
|
|
3 |
|
|
|
4 |
require_once('simple_include.php');
|
|
|
5 |
require_once('calendar_include.php');
|
|
|
6 |
|
|
|
7 |
require_once('./calendar_test.php');
|
|
|
8 |
|
|
|
9 |
class TestOfMonthWeeks extends TestOfCalendar {
|
|
|
10 |
function TestOfMonthWeeks() {
|
|
|
11 |
$this->UnitTestCase('Test of Month Weeks');
|
|
|
12 |
}
|
|
|
13 |
function setUp() {
|
|
|
14 |
$this->cal = new Calendar_Month_Weeks(2003, 10);
|
|
|
15 |
}
|
|
|
16 |
function testPrevDay () {
|
|
|
17 |
$this->assertEqual(30, $this->cal->prevDay());
|
|
|
18 |
}
|
|
|
19 |
function testPrevDay_Array () {
|
|
|
20 |
$this->assertEqual(
|
|
|
21 |
array(
|
|
|
22 |
'year' => 2003,
|
|
|
23 |
'month' => 9,
|
|
|
24 |
'day' => 30,
|
|
|
25 |
'hour' => 0,
|
|
|
26 |
'minute' => 0,
|
|
|
27 |
'second' => 0),
|
|
|
28 |
$this->cal->prevDay('array'));
|
|
|
29 |
}
|
|
|
30 |
function testThisDay () {
|
|
|
31 |
$this->assertEqual(1, $this->cal->thisDay());
|
|
|
32 |
}
|
|
|
33 |
function testNextDay () {
|
|
|
34 |
$this->assertEqual(2, $this->cal->nextDay());
|
|
|
35 |
}
|
|
|
36 |
function testPrevHour () {
|
|
|
37 |
$this->assertEqual(23, $this->cal->prevHour());
|
|
|
38 |
}
|
|
|
39 |
function testThisHour () {
|
|
|
40 |
$this->assertEqual(0, $this->cal->thisHour());
|
|
|
41 |
}
|
|
|
42 |
function testNextHour () {
|
|
|
43 |
$this->assertEqual(1, $this->cal->nextHour());
|
|
|
44 |
}
|
|
|
45 |
function testPrevMinute () {
|
|
|
46 |
$this->assertEqual(59, $this->cal->prevMinute());
|
|
|
47 |
}
|
|
|
48 |
function testThisMinute () {
|
|
|
49 |
$this->assertEqual(0, $this->cal->thisMinute());
|
|
|
50 |
}
|
|
|
51 |
function testNextMinute () {
|
|
|
52 |
$this->assertEqual(1, $this->cal->nextMinute());
|
|
|
53 |
}
|
|
|
54 |
function testPrevSecond () {
|
|
|
55 |
$this->assertEqual(59, $this->cal->prevSecond());
|
|
|
56 |
}
|
|
|
57 |
function testThisSecond () {
|
|
|
58 |
$this->assertEqual(0, $this->cal->thisSecond());
|
|
|
59 |
}
|
|
|
60 |
function testNextSecond () {
|
|
|
61 |
$this->assertEqual(1, $this->cal->nextSecond());
|
|
|
62 |
}
|
|
|
63 |
function testGetTimeStamp() {
|
|
|
64 |
$stamp = mktime(0,0,0,10,1,2003);
|
|
|
65 |
$this->assertEqual($stamp,$this->cal->getTimeStamp());
|
|
|
66 |
}
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
class TestOfMonthWeeksBuild extends TestOfMonthWeeks {
|
|
|
70 |
function TestOfMonthWeeksBuild() {
|
|
|
71 |
$this->UnitTestCase('Test of Month_Weeks::build()');
|
|
|
72 |
}
|
|
|
73 |
function testSize() {
|
|
|
74 |
$this->cal->build();
|
|
|
75 |
$this->assertEqual(5,$this->cal->size());
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
function testFetch() {
|
|
|
79 |
$this->cal->build();
|
|
|
80 |
$i=0;
|
|
|
81 |
while ($Child = $this->cal->fetch()) {
|
|
|
82 |
$i++;
|
|
|
83 |
}
|
|
|
84 |
$this->assertEqual(5,$i);
|
|
|
85 |
}
|
|
|
86 |
/* Recusive dependency issue with SimpleTest
|
|
|
87 |
function testFetchAll() {
|
|
|
88 |
$this->cal->build();
|
|
|
89 |
$children = array();
|
|
|
90 |
$i = 1;
|
|
|
91 |
while ( $Child = $this->cal->fetch() ) {
|
|
|
92 |
$children[$i]=$Child;
|
|
|
93 |
$i++;
|
|
|
94 |
}
|
|
|
95 |
$this->assertEqual($children,$this->cal->fetchAll());
|
|
|
96 |
}
|
|
|
97 |
*/
|
|
|
98 |
function testSelection() {
|
|
|
99 |
include_once CALENDAR_ROOT . 'Week.php';
|
|
|
100 |
$selection = array(new Calendar_Week(2003, 10, 12));
|
|
|
101 |
$this->cal->build($selection);
|
|
|
102 |
$i = 1;
|
|
|
103 |
$expected = (CALENDAR_FIRST_DAY_OF_WEEK == 0) ? 3 : 2;
|
|
|
104 |
while ($Child = $this->cal->fetch()) {
|
|
|
105 |
if ($i == $expected) {
|
|
|
106 |
//12-10-2003 is in the 2nd week of the month if firstDay is Monday,
|
|
|
107 |
//in the 3rd if firstDay is Sunday
|
|
|
108 |
break;
|
|
|
109 |
}
|
|
|
110 |
$i++;
|
|
|
111 |
}
|
|
|
112 |
$this->assertTrue($Child->isSelected());
|
|
|
113 |
}
|
|
|
114 |
function testEmptyDaysBefore_AfterAdjust() {
|
|
|
115 |
$this->cal = new Calendar_Month_Weeks(2004, 0);
|
|
|
116 |
$this->cal->build();
|
|
|
117 |
$expected = (CALENDAR_FIRST_DAY_OF_WEEK == 0) ? 1 : 0;
|
|
|
118 |
$this->assertEqual($expected, $this->cal->tableHelper->getEmptyDaysBefore());
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
if (!defined('TEST_RUNNING')) {
|
|
|
123 |
define('TEST_RUNNING', true);
|
|
|
124 |
$test = &new TestOfMonthWeeks();
|
|
|
125 |
$test->run(new HtmlReporter());
|
|
|
126 |
$test = &new TestOfMonthWeeksBuild();
|
|
|
127 |
$test->run(new HtmlReporter());
|
|
|
128 |
}
|
|
|
129 |
?>
|