@@ -74,13 +74,12 @@ class CookieComponentTest extends CakeTestCase {
74
74
* @access public
75
75
* @return void
76
76
*/
77
- function start () {
77
+ function setUp () {
78
78
$ this ->Controller = new CookieComponentTestController ();
79
79
$ this ->Controller ->constructClasses ();
80
80
$ this ->Controller ->Component ->initialize ($ this ->Controller );
81
81
$ this ->Controller ->beforeFilter ();
82
82
$ this ->Controller ->Component ->startup ($ this ->Controller );
83
- $ this ->Controller ->Cookie ->destroy ();
84
83
}
85
84
86
85
/**
@@ -89,10 +88,22 @@ function start() {
89
88
* @access public
90
89
* @return void
91
90
*/
92
- function end () {
91
+ function tearDown () {
93
92
$ this ->Controller ->Cookie ->destroy ();
94
93
}
95
94
95
+ protected function _setCookieData () {
96
+ $ this ->Controller ->Cookie ->write (array ('Encrytped_array ' => array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' )));
97
+ $ this ->Controller ->Cookie ->write (array ('Encrytped_multi_cookies.name ' => 'CakePHP ' ));
98
+ $ this ->Controller ->Cookie ->write (array ('Encrytped_multi_cookies.version ' => '1.2.0.x ' ));
99
+ $ this ->Controller ->Cookie ->write (array ('Encrytped_multi_cookies.tag ' => 'CakePHP Rocks! ' ));
100
+
101
+ $ this ->Controller ->Cookie ->write (array ('Plain_array ' => array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' )), null , false );
102
+ $ this ->Controller ->Cookie ->write (array ('Plain_multi_cookies.name ' => 'CakePHP ' ), null , false );
103
+ $ this ->Controller ->Cookie ->write (array ('Plain_multi_cookies.version ' => '1.2.0.x ' ), null , false );
104
+ $ this ->Controller ->Cookie ->write (array ('Plain_multi_cookies.tag ' => 'CakePHP Rocks! ' ), null , false );
105
+ }
106
+
96
107
/**
97
108
* test that initialize sets settings from components array
98
109
*
@@ -118,26 +129,14 @@ function testCookieName() {
118
129
$ this ->assertEqual ($ this ->Controller ->Cookie ->name , 'CakeTestCookie ' );
119
130
}
120
131
121
- /**
122
- * testSettingEncryptedCookieData
123
- *
124
- * @access public
125
- * @return void
126
- */
127
- function testSettingEncryptedCookieData () {
128
- $ this ->Controller ->Cookie ->write ('Encrytped_array ' , array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' ));
129
- $ this ->Controller ->Cookie ->write ('Encrytped_multi_cookies.name ' , 'CakePHP ' );
130
- $ this ->Controller ->Cookie ->write ('Encrytped_multi_cookies.version ' , '1.2.0.x ' );
131
- $ this ->Controller ->Cookie ->write ('Encrytped_multi_cookies.tag ' , 'CakePHP Rocks! ' );
132
- }
133
-
134
132
/**
135
133
* testReadEncryptedCookieData
136
134
*
137
135
* @access public
138
136
* @return void
139
137
*/
140
138
function testReadEncryptedCookieData () {
139
+ $ this ->_setCookieData ();
141
140
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_array ' );
142
141
$ expected = array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' );
143
142
$ this ->assertEqual ($ data , $ expected );
@@ -147,26 +146,15 @@ function testReadEncryptedCookieData() {
147
146
$ this ->assertEqual ($ data , $ expected );
148
147
}
149
148
150
- /**
151
- * testSettingPlainCookieData
152
- *
153
- * @access public
154
- * @return void
155
- */
156
- function testSettingPlainCookieData () {
157
- $ this ->Controller ->Cookie ->write ('Plain_array ' , array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' ), false );
158
- $ this ->Controller ->Cookie ->write ('Plain_multi_cookies.name ' , 'CakePHP ' , false );
159
- $ this ->Controller ->Cookie ->write ('Plain_multi_cookies.version ' , '1.2.0.x ' , false );
160
- $ this ->Controller ->Cookie ->write ('Plain_multi_cookies.tag ' , 'CakePHP Rocks! ' , false );
161
- }
162
-
163
149
/**
164
150
* testReadPlainCookieData
165
151
*
166
152
* @access public
167
153
* @return void
168
154
*/
169
155
function testReadPlainCookieData () {
156
+ $ this ->_setCookieData ();
157
+
170
158
$ data = $ this ->Controller ->Cookie ->read ('Plain_array ' );
171
159
$ expected = array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' );
172
160
$ this ->assertEqual ($ data , $ expected );
@@ -201,6 +189,7 @@ function testWritePlainCookieArray() {
201
189
* @return void
202
190
*/
203
191
function testReadingCookieValue () {
192
+ $ this ->_setCookieData ();
204
193
$ data = $ this ->Controller ->Cookie ->read ();
205
194
$ expected = array (
206
195
'Encrytped_array ' => array (
@@ -229,15 +218,15 @@ function testReadingCookieValue() {
229
218
* @return void
230
219
*/
231
220
function testDeleteCookieValue () {
221
+ $ this ->_setCookieData ();
232
222
$ this ->Controller ->Cookie ->delete ('Encrytped_multi_cookies.name ' );
233
223
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_multi_cookies ' );
234
224
$ expected = array ('version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' );
235
225
$ this ->assertEqual ($ data , $ expected );
236
226
237
227
$ this ->Controller ->Cookie ->delete ('Encrytped_array ' );
238
228
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_array ' );
239
- $ expected = array ();
240
- $ this ->assertEqual ($ data , $ expected );
229
+ $ this ->assertNull ($ data );
241
230
242
231
$ this ->Controller ->Cookie ->delete ('Plain_multi_cookies.name ' );
243
232
$ data = $ this ->Controller ->Cookie ->read ('Plain_multi_cookies ' );
@@ -246,28 +235,7 @@ function testDeleteCookieValue() {
246
235
247
236
$ this ->Controller ->Cookie ->delete ('Plain_array ' );
248
237
$ data = $ this ->Controller ->Cookie ->read ('Plain_array ' );
249
- $ expected = array ();
250
- $ this ->assertEqual ($ data , $ expected );
251
- }
252
-
253
- /**
254
- * testSettingCookiesWithArray
255
- *
256
- * @access public
257
- * @return void
258
- */
259
- function testSettingCookiesWithArray () {
260
- $ this ->Controller ->Cookie ->destroy ();
261
-
262
- $ this ->Controller ->Cookie ->write (array ('Encrytped_array ' => array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' )));
263
- $ this ->Controller ->Cookie ->write (array ('Encrytped_multi_cookies.name ' => 'CakePHP ' ));
264
- $ this ->Controller ->Cookie ->write (array ('Encrytped_multi_cookies.version ' => '1.2.0.x ' ));
265
- $ this ->Controller ->Cookie ->write (array ('Encrytped_multi_cookies.tag ' => 'CakePHP Rocks! ' ));
266
-
267
- $ this ->Controller ->Cookie ->write (array ('Plain_array ' => array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' )), null , false );
268
- $ this ->Controller ->Cookie ->write (array ('Plain_multi_cookies.name ' => 'CakePHP ' ), null , false );
269
- $ this ->Controller ->Cookie ->write (array ('Plain_multi_cookies.version ' => '1.2.0.x ' ), null , false );
270
- $ this ->Controller ->Cookie ->write (array ('Plain_multi_cookies.tag ' => 'CakePHP Rocks! ' ), null , false );
238
+ $ this ->assertNull ($ data );
271
239
}
272
240
273
241
/**
@@ -277,6 +245,8 @@ function testSettingCookiesWithArray() {
277
245
* @return void
278
246
*/
279
247
function testReadingCookieArray () {
248
+ $ this ->_setCookieData ();
249
+
280
250
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_array.name ' );
281
251
$ expected = 'CakePHP ' ;
282
252
$ this ->assertEqual ($ data , $ expected );
@@ -333,23 +303,18 @@ function testReadingCookieArray() {
333
303
* @return void
334
304
*/
335
305
function testReadingCookieDataOnStartup () {
336
- $ this ->Controller ->Cookie ->destroy ();
337
306
338
307
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_array ' );
339
- $ expected = array ();
340
- $ this ->assertEqual ($ data , $ expected );
308
+ $ this ->assertNull ($ data );
341
309
342
310
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_multi_cookies ' );
343
- $ expected = array ();
344
- $ this ->assertEqual ($ data , $ expected );
311
+ $ this ->assertNull ($ data );
345
312
346
313
$ data = $ this ->Controller ->Cookie ->read ('Plain_array ' );
347
- $ expected = array ();
348
- $ this ->assertEqual ($ data , $ expected );
314
+ $ this ->assertNull ($ data );
349
315
350
316
$ data = $ this ->Controller ->Cookie ->read ('Plain_multi_cookies ' );
351
- $ expected = array ();
352
- $ this ->assertEqual ($ data , $ expected );
317
+ $ this ->assertNull ($ data );
353
318
354
319
$ _COOKIE ['CakeTestCookie ' ] = array (
355
320
'Encrytped_array ' => $ this ->__encrypt (array ('name ' => 'CakePHP ' , 'version ' => '1.2.0.x ' , 'tag ' =>'CakePHP Rocks! ' )),
@@ -391,19 +356,19 @@ function testReadingCookieDataOnStartup() {
391
356
*/
392
357
function testReadingCookieDataWithoutStartup () {
393
358
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_array ' );
394
- $ expected = array () ;
359
+ $ expected = null ;
395
360
$ this ->assertEqual ($ data , $ expected );
396
361
397
362
$ data = $ this ->Controller ->Cookie ->read ('Encrytped_multi_cookies ' );
398
- $ expected = array () ;
363
+ $ expected = null ;
399
364
$ this ->assertEqual ($ data , $ expected );
400
365
401
366
$ data = $ this ->Controller ->Cookie ->read ('Plain_array ' );
402
- $ expected = array () ;
367
+ $ expected = null ;
403
368
$ this ->assertEqual ($ data , $ expected );
404
369
405
370
$ data = $ this ->Controller ->Cookie ->read ('Plain_multi_cookies ' );
406
- $ expected = array () ;
371
+ $ expected = null ;
407
372
$ this ->assertEqual ($ data , $ expected );
408
373
409
374
$ _COOKIE ['CakeTestCookie ' ] = array (
0 commit comments