PHPUnit testing for Craft plugins or controllers
There is a good example of testing with PHPUnit in a Craft plugin here: https://github.com/selvinortiz/craft.loath and an example on how to stub out the global craft() class here: Stub out the global craft() object for PHPUnit tests

Note that testing in Craft should be a lot easier/convenient in the upcoming Craft 3.