hi
i have old code which didnt use TDD now i want to write a test for a function which looks like this
function somefunction($someargs){
// do a few checks on $someargs
$database = new DB_PG();
$result = $database->select($query);
// do some changes on result
return $result;
}
since im not much expirienced with phpunit and testing in general my question is: how can i mock DB_PG? i tried getMock() in my test, but since the function uses "new" to get an instance my mock object is ignored, which makes sense
so i see only 2 options
- some features of phpunit i dont know - which is the reason i ask here ^^
- i have to modify the old code - which i know would be better
so, anyone knows an answer for option 1?
thx all