title: Mocking PHP functions in unit tests
body: <p>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 <code>mysql</code> functions. In my tests of a wrapper class for the <code>mail</code> function I want to mock PHPs <code>mail</code> function. These are just some examples.</p>
  
  <p>The point is: I don't (always) want to test if my Mail class sends e-mail, I want to test how it calls the <code>mail</code> function. I want to be able to control what these functions return. I want to be able to test my Database class without needing a database, fixtures and that whole lot.</p>
  
  <p>I've got some experience with testing Ruby code, and Test::Unit and RSpec make it very easy to test code in isolation. I'm new to testing PHP and it feels like I'm testing a lot more than I should need to, in order to get my tests to pass.</p>
  
  <p>Is there a way in SimpleTest or PhpUnit or some other testing framework that makes this possible or easier?</p>