I\'m unit-testing some PHP code with SimpleTest and I\'ve run into trouble. In my tests of a database class I want to be able to set an expectation for PHPs mysql
f
In PHP 5.3+ environment you may workaround the need to use runkit
extension by hacking the namespaces. The only requirement in that the function calls do not use fully-qualified namespace like \mysql_query()
- and they usually don't. Then you can define the same function in your test, by defining the test in a namespace, and PHP will call your function instead of the global one. Personally I use this approach to stub the time()
function call. Here is a nice example with the mockery framework