1 | <?php |
---|
2 | // $Id: util_textual_test.php,v 1.1 2004/08/16 12:56:10 hfuecks Exp $ |
---|
3 | |
---|
4 | require_once('simple_include.php'); |
---|
5 | require_once('calendar_include.php'); |
---|
6 | |
---|
7 | require_once('./decorator_test.php'); |
---|
8 | |
---|
9 | class TestOfUtilTextual extends UnitTestCase { |
---|
10 | var $mockengine; |
---|
11 | var $mockcal; |
---|
12 | function TestOfUtilTextual() { |
---|
13 | $this->UnitTestCase('Test of Calendar_Util_Textual'); |
---|
14 | } |
---|
15 | function setUp() { |
---|
16 | $this->mockengine = new Mock_Calendar_Engine($this); |
---|
17 | $this->mockcal = new Mock_Calendar_Second($this); |
---|
18 | $this->mockcal->setReturnValue('prevYear',2002); |
---|
19 | $this->mockcal->setReturnValue('thisYear',2003); |
---|
20 | $this->mockcal->setReturnValue('nextYear',2004); |
---|
21 | $this->mockcal->setReturnValue('prevMonth',9); |
---|
22 | $this->mockcal->setReturnValue('thisMonth',10); |
---|
23 | $this->mockcal->setReturnValue('nextMonth',11); |
---|
24 | $this->mockcal->setReturnValue('prevDay',14); |
---|
25 | $this->mockcal->setReturnValue('thisDay',15); |
---|
26 | $this->mockcal->setReturnValue('nextDay',16); |
---|
27 | $this->mockcal->setReturnValue('prevHour',12); |
---|
28 | $this->mockcal->setReturnValue('thisHour',13); |
---|
29 | $this->mockcal->setReturnValue('nextHour',14); |
---|
30 | $this->mockcal->setReturnValue('prevMinute',29); |
---|
31 | $this->mockcal->setReturnValue('thisMinute',30); |
---|
32 | $this->mockcal->setReturnValue('nextMinute',31); |
---|
33 | $this->mockcal->setReturnValue('prevSecond',44); |
---|
34 | $this->mockcal->setReturnValue('thisSecond',45); |
---|
35 | $this->mockcal->setReturnValue('nextSecond',46); |
---|
36 | $this->mockcal->setReturnValue('getEngine',$this->mockengine); |
---|
37 | $this->mockcal->setReturnValue('getTimestamp',12345); |
---|
38 | } |
---|
39 | function tearDown() { |
---|
40 | unset ( $this->engine ); |
---|
41 | unset ( $this->mockcal ); |
---|
42 | } |
---|
43 | function testMonthNamesLong() { |
---|
44 | $monthNames = array( |
---|
45 | 1=>'January', |
---|
46 | 2=>'February', |
---|
47 | 3=>'March', |
---|
48 | 4=>'April', |
---|
49 | 5=>'May', |
---|
50 | 6=>'June', |
---|
51 | 7=>'July', |
---|
52 | 8=>'August', |
---|
53 | 9=>'September', |
---|
54 | 10=>'October', |
---|
55 | 11=>'November', |
---|
56 | 12=>'December', |
---|
57 | ); |
---|
58 | $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames()); |
---|
59 | } |
---|
60 | function testMonthNamesShort() { |
---|
61 | $monthNames = array( |
---|
62 | 1=>'Jan', |
---|
63 | 2=>'Feb', |
---|
64 | 3=>'Mar', |
---|
65 | 4=>'Apr', |
---|
66 | 5=>'May', |
---|
67 | 6=>'Jun', |
---|
68 | 7=>'Jul', |
---|
69 | 8=>'Aug', |
---|
70 | 9=>'Sep', |
---|
71 | 10=>'Oct', |
---|
72 | 11=>'Nov', |
---|
73 | 12=>'Dec', |
---|
74 | ); |
---|
75 | $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames('short')); |
---|
76 | } |
---|
77 | function testMonthNamesTwo() { |
---|
78 | $monthNames = array( |
---|
79 | 1=>'Ja', |
---|
80 | 2=>'Fe', |
---|
81 | 3=>'Ma', |
---|
82 | 4=>'Ap', |
---|
83 | 5=>'Ma', |
---|
84 | 6=>'Ju', |
---|
85 | 7=>'Ju', |
---|
86 | 8=>'Au', |
---|
87 | 9=>'Se', |
---|
88 | 10=>'Oc', |
---|
89 | 11=>'No', |
---|
90 | 12=>'De', |
---|
91 | ); |
---|
92 | $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames('two')); |
---|
93 | } |
---|
94 | function testMonthNamesOne() { |
---|
95 | $monthNames = array( |
---|
96 | 1=>'J', |
---|
97 | 2=>'F', |
---|
98 | 3=>'M', |
---|
99 | 4=>'A', |
---|
100 | 5=>'M', |
---|
101 | 6=>'J', |
---|
102 | 7=>'J', |
---|
103 | 8=>'A', |
---|
104 | 9=>'S', |
---|
105 | 10=>'O', |
---|
106 | 11=>'N', |
---|
107 | 12=>'D', |
---|
108 | ); |
---|
109 | $this->assertEqual($monthNames,Calendar_Util_Textual::monthNames('one')); |
---|
110 | } |
---|
111 | function testWeekdayNamesLong() { |
---|
112 | $weekdayNames = array( |
---|
113 | 0=>'Sunday', |
---|
114 | 1=>'Monday', |
---|
115 | 2=>'Tuesday', |
---|
116 | 3=>'Wednesday', |
---|
117 | 4=>'Thursday', |
---|
118 | 5=>'Friday', |
---|
119 | 6=>'Saturday', |
---|
120 | ); |
---|
121 | $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames()); |
---|
122 | } |
---|
123 | function testWeekdayNamesShort() { |
---|
124 | $weekdayNames = array( |
---|
125 | 0=>'Sun', |
---|
126 | 1=>'Mon', |
---|
127 | 2=>'Tue', |
---|
128 | 3=>'Wed', |
---|
129 | 4=>'Thu', |
---|
130 | 5=>'Fri', |
---|
131 | 6=>'Sat', |
---|
132 | ); |
---|
133 | $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames('short')); |
---|
134 | } |
---|
135 | function testWeekdayNamesTwo() { |
---|
136 | $weekdayNames = array( |
---|
137 | 0=>'Su', |
---|
138 | 1=>'Mo', |
---|
139 | 2=>'Tu', |
---|
140 | 3=>'We', |
---|
141 | 4=>'Th', |
---|
142 | 5=>'Fr', |
---|
143 | 6=>'Sa', |
---|
144 | ); |
---|
145 | $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames('two')); |
---|
146 | } |
---|
147 | function testWeekdayNamesOne() { |
---|
148 | $weekdayNames = array( |
---|
149 | 0=>'S', |
---|
150 | 1=>'M', |
---|
151 | 2=>'T', |
---|
152 | 3=>'W', |
---|
153 | 4=>'T', |
---|
154 | 5=>'F', |
---|
155 | 6=>'S', |
---|
156 | ); |
---|
157 | $this->assertEqual($weekdayNames,Calendar_Util_Textual::weekdayNames('one')); |
---|
158 | } |
---|
159 | function testPrevMonthNameShort() { |
---|
160 | $this->assertEqual('Sep',Calendar_Util_Textual::prevMonthName($this->mockcal,'short')); |
---|
161 | } |
---|
162 | function testThisMonthNameShort() { |
---|
163 | $this->assertEqual('Oct',Calendar_Util_Textual::thisMonthName($this->mockcal,'short')); |
---|
164 | } |
---|
165 | function testNextMonthNameShort() { |
---|
166 | $this->assertEqual('Nov',Calendar_Util_Textual::nextMonthName($this->mockcal,'short')); |
---|
167 | } |
---|
168 | function testThisDayNameShort() { |
---|
169 | $this->assertEqual('Wed',Calendar_Util_Textual::thisDayName($this->mockcal,'short')); |
---|
170 | } |
---|
171 | function testOrderedWeekdaysShort() { |
---|
172 | $weekdayNames = array( |
---|
173 | 0=>'Sun', |
---|
174 | 1=>'Mon', |
---|
175 | 2=>'Tue', |
---|
176 | 3=>'Wed', |
---|
177 | 4=>'Thu', |
---|
178 | 5=>'Fri', |
---|
179 | 6=>'Sat', |
---|
180 | ); |
---|
181 | $this->assertEqual($weekdayNames,Calendar_Util_Textual::orderedWeekdays($this->mockcal,'short')); |
---|
182 | } |
---|
183 | |
---|
184 | } |
---|
185 | |
---|
186 | if (!defined('TEST_RUNNING')) { |
---|
187 | define('TEST_RUNNING', true); |
---|
188 | $test = &new TestOfUtilTextual(); |
---|
189 | $test->run(new HtmlReporter()); |
---|
190 | } |
---|
191 | ?> |
---|