PHP in Action Rotating Header Image

Posts under ‘Testing’

Testing Smarty templates

I follow the principle that you should test everything that could possibly fail. And I would like to have unit tests for everything; tests that exercise each small behavior in isolation. The components that are easiest to unit test are typically class and methods in plain object-oriented code. Not everything falls into that category, though. [...]

Paparrazzi testing

Uncle Bob (Robert C. Martin) has blogged about testing GUIs (web interfaces, that is; JSP and Rails) without having to run a web server. I don't think it answers all the challenges I'm up against currently, but it inspired me to some heavy thinking about the essential issue of complete and not too cumbersome [...]

Anonymous functions for testing

I've been using mock objects when testing code that uses files and other stuff that's hard to test because there are too many effects on the code's surroundings and you have to test . I've been doing that on an ad hoc basis. Now Mike Naberezny has an interesting generalized class for wrapping PHP modules [...]

Spaghetti? Ravioli? Farfalle?

In a blog post by Paul M. Jones, he quotes comments from slashdot claiming that TDD leads to “ravioli code”:
The problem is that it [Ravioli Code] tends to lead to functions (methods, etc.) without true coherence, and it often leaves the code to implement even something fairly simple scattered over a very large number of [...]

Running PHP tests inside Vim

I created my own test runner to run tests inside Vim, I can’t remember how long ago. Must be a year or two. I never shared it with the world. It was too primitive for anyone else to use. Then, recently, I decided to try re-implementing it in a more serious way. That meant using [...]

Tips for web testing

I just started listing the techniques I've learned when writing tests to exercise the web interface of a PHP application. This is from my experience and my personal preferences; it's not the final word or necessarily right for everyone.
The idea of being able to record and play back tests, as you can do with [...]