title: How to use output buffering inside PHPUnit test?
body: <p>I'm using PHPUnit to test a function which downloads a file. I want to test that the correct file is downloaded and so my idea was to check the output of the function. I'm trying to use output buffering:</p>
  
  <pre><code>ob_start();
  $viewer-&gt;downloadById($fileId);
  $output = ob_get_flush();
  $this-&gt;assertEquals($expectedFileContents,$output);
  </code></pre>
  
  <p>The test passes/fails when it should, which is good. My issue is that the contents of the output buffer is also printed to the console. How do I hide this?</p>