title: In PHPUnit, how can I mock a function that is not part of a class?
body: <p>The project I'm currently working on contains a mixture of object-oriented and procedural PHP code. So I have something like this:</p>
  
  <pre><code>function doStuff($value)
  {
      $x = $value + 1;
  
      return $x;
  }
  
  class MyClass
  {
      private $field;
  
      public function setMyValue($amount)
      {
          $this-&gt;field = doStuff($amount) + doStuff(2 * $amount);
      }
  }
  </code></pre>
  
  <p>There are a few of these dependencies, but there are few (you can count them using one hand). However, I need to write unit tests for the classes (using PHPUnit) and I have no idea how to mock the functions that come from the procedural side (in this case <code>doStuff</code>). From what I've seen, the mocking functionality in PHPUnit works only with classes.</p>
  
  <p>I would just do it without any mock at all, but the problem is some of these functions do some IO operations; I don't think it's a very good idea not to mock them somehow.</p>
  
  <p>How can I solve this ?</p>