Subversion Repositories Applications.gtt

Rev

Rev 61 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 jpm 1
<?php
2
// $Id: decorator_test.php,v 1.1 2004/05/24 22:25:43 quipo Exp $
3
 
4
require_once('simple_include.php');
5
require_once('calendar_include.php');
6
 
7
Mock::generate('Calendar_Engine_Interface','Mock_Calendar_Engine');
8
Mock::generate('Calendar_Second','Mock_Calendar_Second');
9
Mock::generate('Calendar_Week','Mock_Calendar_Week');
10
Mock::generate('Calendar_Day','Mock_Calendar_Day');
11
 
12
class TestOfDecorator extends UnitTestCase {
13
    var $mockengine;
14
    var $mockcal;
15
    var $decorator;
16
    function TestOfDecorator() {
17
        $this->UnitTestCase('Test of Calendar_Decorator');
18
    }
19
    function setUp() {
20
        $this->mockengine = new Mock_Calendar_Engine($this);
21
        $this->mockcal = new Mock_Calendar_Second($this);
22
        $this->mockcal->setReturnValue('prevYear',2002);
23
        $this->mockcal->setReturnValue('thisYear',2003);
24
        $this->mockcal->setReturnValue('nextYear',2004);
25
        $this->mockcal->setReturnValue('prevMonth',9);
26
        $this->mockcal->setReturnValue('thisMonth',10);
27
        $this->mockcal->setReturnValue('nextMonth',11);
28
        $this->mockcal->setReturnValue('prevDay',14);
29
        $this->mockcal->setReturnValue('thisDay',15);
30
        $this->mockcal->setReturnValue('nextDay',16);
31
        $this->mockcal->setReturnValue('prevHour',12);
32
        $this->mockcal->setReturnValue('thisHour',13);
33
        $this->mockcal->setReturnValue('nextHour',14);
34
        $this->mockcal->setReturnValue('prevMinute',29);
35
        $this->mockcal->setReturnValue('thisMinute',30);
36
        $this->mockcal->setReturnValue('nextMinute',31);
37
        $this->mockcal->setReturnValue('prevSecond',44);
38
        $this->mockcal->setReturnValue('thisSecond',45);
39
        $this->mockcal->setReturnValue('nextSecond',46);
40
        $this->mockcal->setReturnValue('getEngine',$this->mockengine);
41
        $this->mockcal->setReturnValue('getTimestamp',12345);
42
 
43
    }
44
    function tearDown() {
45
        unset ( $this->engine );
46
        unset ( $this->mockcal );
47
    }
48
    function testPrevYear() {
49
        $this->mockcal->expectOnce('prevYear',array('int'));
50
        $Decorator =& new Calendar_Decorator($this->mockcal);
51
        $this->assertEqual(2002,$Decorator->prevYear());
52
    }
53
    function testThisYear() {
54
        $this->mockcal->expectOnce('thisYear',array('int'));
55
        $Decorator =& new Calendar_Decorator($this->mockcal);
56
        $this->assertEqual(2003,$Decorator->thisYear());
57
    }
58
    function testNextYear() {
59
        $this->mockcal->expectOnce('nextYear',array('int'));
60
        $Decorator =& new Calendar_Decorator($this->mockcal);
61
        $this->assertEqual(2004,$Decorator->nextYear());
62
    }
63
    function testPrevMonth() {
64
        $this->mockcal->expectOnce('prevMonth',array('int'));
65
        $Decorator =& new Calendar_Decorator($this->mockcal);
66
        $this->assertEqual(9,$Decorator->prevMonth());
67
    }
68
    function testThisMonth() {
69
        $this->mockcal->expectOnce('thisMonth',array('int'));
70
        $Decorator =& new Calendar_Decorator($this->mockcal);
71
        $this->assertEqual(10,$Decorator->thisMonth());
72
    }
73
    function testNextMonth() {
74
        $this->mockcal->expectOnce('nextMonth',array('int'));
75
        $Decorator =& new Calendar_Decorator($this->mockcal);
76
        $this->assertEqual(11,$Decorator->nextMonth());
77
    }
78
    function testPrevWeek() {
79
        $mockweek = & new Mock_Calendar_Week($this);
80
        $mockweek->setReturnValue('prevWeek',1);
81
        $mockweek->expectOnce('prevWeek',array('n_in_month'));
82
        $Decorator =& new Calendar_Decorator($mockweek);
83
        $this->assertEqual(1,$Decorator->prevWeek());
84
    }
85
    function testThisWeek() {
86
        $mockweek = & new Mock_Calendar_Week($this);
87
        $mockweek->setReturnValue('thisWeek',2);
88
        $mockweek->expectOnce('thisWeek',array('n_in_month'));
89
        $Decorator =& new Calendar_Decorator($mockweek);
90
        $this->assertEqual(2,$Decorator->thisWeek());
91
    }
92
    function testNextWeek() {
93
        $mockweek = & new Mock_Calendar_Week($this);
94
        $mockweek->setReturnValue('nextWeek',3);
95
        $mockweek->expectOnce('nextWeek',array('n_in_month'));
96
        $Decorator =& new Calendar_Decorator($mockweek);
97
        $this->assertEqual(3,$Decorator->nextWeek());
98
    }
99
    function testPrevDay() {
100
        $this->mockcal->expectOnce('prevDay',array('int'));
101
        $Decorator =& new Calendar_Decorator($this->mockcal);
102
        $this->assertEqual(14,$Decorator->prevDay());
103
    }
104
    function testThisDay() {
105
        $this->mockcal->expectOnce('thisDay',array('int'));
106
        $Decorator =& new Calendar_Decorator($this->mockcal);
107
        $this->assertEqual(15,$Decorator->thisDay());
108
    }
109
    function testNextDay() {
110
        $this->mockcal->expectOnce('nextDay',array('int'));
111
        $Decorator =& new Calendar_Decorator($this->mockcal);
112
        $this->assertEqual(16,$Decorator->nextDay());
113
    }
114
    function testPrevHour() {
115
        $this->mockcal->expectOnce('prevHour',array('int'));
116
        $Decorator =& new Calendar_Decorator($this->mockcal);
117
        $this->assertEqual(12,$Decorator->prevHour());
118
    }
119
    function testThisHour() {
120
        $this->mockcal->expectOnce('thisHour',array('int'));
121
        $Decorator =& new Calendar_Decorator($this->mockcal);
122
        $this->assertEqual(13,$Decorator->thisHour());
123
    }
124
    function testNextHour() {
125
        $this->mockcal->expectOnce('nextHour',array('int'));
126
        $Decorator =& new Calendar_Decorator($this->mockcal);
127
        $this->assertEqual(14,$Decorator->nextHour());
128
    }
129
    function testPrevMinute() {
130
        $this->mockcal->expectOnce('prevMinute',array('int'));
131
        $Decorator =& new Calendar_Decorator($this->mockcal);
132
        $this->assertEqual(29,$Decorator->prevMinute());
133
    }
134
    function testThisMinute() {
135
        $this->mockcal->expectOnce('thisMinute',array('int'));
136
        $Decorator =& new Calendar_Decorator($this->mockcal);
137
        $this->assertEqual(30,$Decorator->thisMinute());
138
    }
139
    function testNextMinute() {
140
        $this->mockcal->expectOnce('nextMinute',array('int'));
141
        $Decorator =& new Calendar_Decorator($this->mockcal);
142
        $this->assertEqual(31,$Decorator->nextMinute());
143
    }
144
    function testPrevSecond() {
145
        $this->mockcal->expectOnce('prevSecond',array('int'));
146
        $Decorator =& new Calendar_Decorator($this->mockcal);
147
        $this->assertEqual(44,$Decorator->prevSecond());
148
    }
149
    function testThisSecond() {
150
        $this->mockcal->expectOnce('thisSecond',array('int'));
151
        $Decorator =& new Calendar_Decorator($this->mockcal);
152
        $this->assertEqual(45,$Decorator->thisSecond());
153
    }
154
    function testNextSecond() {
155
        $this->mockcal->expectOnce('nextSecond',array('int'));
156
        $Decorator =& new Calendar_Decorator($this->mockcal);
157
        $this->assertEqual(46,$Decorator->nextSecond());
158
    }
159
    function testGetEngine() {
160
        $Decorator =& new Calendar_Decorator($this->mockcal);
161
        $this->assertIsA($Decorator->getEngine(),'Mock_Calendar_Engine');
162
    }
163
    function testSetTimestamp() {
164
        $this->mockcal->expectOnce('setTimestamp',array('12345'));
165
        $Decorator =& new Calendar_Decorator($this->mockcal);
166
        $Decorator->setTimestamp('12345');
167
    }
168
    function testGetTimestamp() {
169
        $Decorator =& new Calendar_Decorator($this->mockcal);
170
        $this->assertEqual(12345,$Decorator->getTimestamp());
171
    }
172
    function testSetSelected() {
173
        $this->mockcal->expectOnce('setSelected',array(true));
174
        $Decorator =& new Calendar_Decorator($this->mockcal);
175
        $Decorator->setSelected();
176
    }
177
    function testIsSelected() {
178
        $this->mockcal->setReturnValue('isSelected',true);
179
        $Decorator =& new Calendar_Decorator($this->mockcal);
180
        $this->assertTrue($Decorator->isSelected());
181
    }
182
    function testAdjust() {
183
        $this->mockcal->expectOnce('adjust',array());
184
        $Decorator =& new Calendar_Decorator($this->mockcal);
185
        $Decorator->adjust();
186
    }
187
    function testToArray() {
188
        $this->mockcal->expectOnce('toArray',array(12345));
189
        $testArray = array('foo'=>'bar');
190
        $this->mockcal->setReturnValue('toArray',$testArray);
191
        $Decorator =& new Calendar_Decorator($this->mockcal);
192
        $this->assertEqual($testArray,$Decorator->toArray(12345));
193
    }
194
    function testReturnValue() {
195
        $this->mockcal->expectOnce('returnValue',array('a','b','c','d'));
196
        $this->mockcal->setReturnValue('returnValue','foo');
197
        $Decorator =& new Calendar_Decorator($this->mockcal);
198
        $this->assertEqual('foo',$Decorator->returnValue('a','b','c','d'));
199
    }
200
    function testSetFirst() {
201
        $mockday = & new Mock_Calendar_Day($this);
202
        $mockday->expectOnce('setFirst',array(true));
203
        $Decorator =& new Calendar_Decorator($mockday);
204
        $Decorator->setFirst();
205
    }
206
    function testSetLast() {
207
        $mockday = & new Mock_Calendar_Day($this);
208
        $mockday->expectOnce('setLast',array(true));
209
        $Decorator =& new Calendar_Decorator($mockday);
210
        $Decorator->setLast();
211
    }
212
    function testIsFirst() {
213
        $mockday = & new Mock_Calendar_Day($this);
214
        $mockday->setReturnValue('isFirst',TRUE);
215
        $Decorator =& new Calendar_Decorator($mockday);
216
        $this->assertTrue($Decorator->isFirst());
217
    }
218
    function testIsLast() {
219
        $mockday = & new Mock_Calendar_Day($this);
220
        $mockday->setReturnValue('isLast',TRUE);
221
        $Decorator =& new Calendar_Decorator($mockday);
222
        $this->assertTrue($Decorator->isLast());
223
    }
224
    function testSetEmpty() {
225
        $mockday = & new Mock_Calendar_Day($this);
226
        $mockday->expectOnce('setEmpty',array(true));
227
        $Decorator =& new Calendar_Decorator($mockday);
228
        $Decorator->setEmpty();
229
    }
230
    function testIsEmpty() {
231
        $mockday = & new Mock_Calendar_Day($this);
232
        $mockday->setReturnValue('isEmpty',TRUE);
233
        $Decorator =& new Calendar_Decorator($mockday);
234
        $this->assertTrue($Decorator->isEmpty());
235
    }
236
    function testBuild() {
237
        $testArray=array('foo'=>'bar');
238
        $this->mockcal->expectOnce('build',array($testArray));
239
        $Decorator =& new Calendar_Decorator($this->mockcal);
240
        $Decorator->build($testArray);
241
    }
242
    function testFetch() {
243
        $this->mockcal->expectOnce('fetch',array());
244
        $Decorator =& new Calendar_Decorator($this->mockcal);
245
        $Decorator->fetch();
246
    }
247
    function testFetchAll() {
248
        $this->mockcal->expectOnce('fetchAll',array());
249
        $Decorator =& new Calendar_Decorator($this->mockcal);
250
        $Decorator->fetchAll();
251
    }
252
    function testSize() {
253
        $this->mockcal->expectOnce('size',array());
254
        $Decorator =& new Calendar_Decorator($this->mockcal);
255
        $Decorator->size();
256
    }
257
    function testIsValid() {
258
        $this->mockcal->expectOnce('isValid',array());
259
        $Decorator =& new Calendar_Decorator($this->mockcal);
260
        $Decorator->isValid();
261
    }
262
    function testGetValidator() {
263
        $this->mockcal->expectOnce('getValidator',array());
264
        $Decorator =& new Calendar_Decorator($this->mockcal);
265
        $Decorator->getValidator();
266
    }
267
}
268
?>