Tag Archives: testing

Testing Cron Jobs for the correct user

Testing Cron Jobs in Linux can be a pain – especially if you’re using a tool like CPanel which abstracts away some of the processing. However, with a couple of quick commands, it’s possible to track down where your cron jobs may be failing and get them running smooth as silk.
Continue reading

Tagged , , ,

Testing using Mocks & Stubs with PHPUnit

Now that we’ve got PHPUnit setup, we need to start writing the unit tests.

My immediate needs are to Unit test two classes, the first being a basic structure with getters and setters with small calculations performed. The PHPUnit manual provides a great starting point for testing this class in chapters 4 and 6, so I wont cover those here.

The second class, however, maintains a list of objects of the first type as well as performing some calculations based on them. Since we’re doing unit tests and not integration tests, we need to make sure that the results of our second class are predictable which means decoupling it from the first class. This obviously presents a problem whereby it would no longer function without the first class. This is where Mocks and Stubs come in.
Continue reading

Tagged , , ,