Tuesday, October 23, 2012

Fake CakeSession and CookieComponent for tests

Hello all,
As those of you who've used Cake's testing framework may know, session (and cookie) handling is pretty inconsistent between the console stdout, console stderr, and browser test environments. The attached test file shows the misbehaviours I've encountered.

My question for the group is whether people think it would be a good idea to inject a special CakeSession and CookieComponent (which has similar problems) when running tests. The behaviour would be to cause App, ClassRegistry and friends to return test versions which would be reset automatically between tests.

This would remove all the issues identified in the test file. Even if PHPUnit's @backupGlobals worked (which it doesn't for me), it would not correct the stdout failure (caused by a 'headers already sent' type issue I think).

The only disadvantage I can think of is we'd need some way of getting the originals for CakeSessionTest and CookieComponentTest.

What does everyone think?

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: