title: mock php's resource type for unittesting
body: <p>I have to write tests for a php Class that uses a resource type created by an apache extension we use, but let's say it's a database class with the mysql resource type.</p>
  
  <p>obviously i'd like to mock those global functions, but how to fake the return type when the class checks if the resource was created fine?</p>
  
  <p>the Resource page in php's doc even have one comment complaining about the inability of mocks for testing. Is that the final answer?</p>
  
  <p>let's say i have the (lame example) code:</p>
  
  <pre><code>class DB {
    function init(){
      $this-&gt;handle = mysql_connect('myserver');
      if( get_resource_type($this-&gt;handle) != 'mysql' ) return false;
        return true;
      }
  }
  </code></pre>
  
  <p>and then the tests that test for a success and a failure, by mocking <code>mysql_connect</code>.</p>