title: PHPUnit: Don't report Symfony exceptions rendered to HTTP errors
body: <p>I am running integration tests with PHPUnit (6.5.8, upgraded to 7.1.5, no difference) on an API built with Symfony (Flex 1.0).</p>
  
  <p>I have several controllers that throw exceptions one way or the other, for example for security reasons (e.g. using the <code>@IsGranted</code> annotation). </p>
  
  <p>Those exceptions get converted to JSON via the <a href="https://symfony.com/doc/master/bundles/FOSRestBundle/4-exception-controller-support.html" rel="noreferrer">ExceptionController of the FOSRestBundle</a>. This works fine, <strong>also in the tests</strong>.</p>
  
  <p>I am testing those exceptions being converted by looking checking status codes, etc, example:</p>
  
  <pre><code>public function testSecurity() {
      $this-&gt;request('GET', '/foo');
      $this-&gt;assertStatusCode(403);
  }
  </code></pre>
  
  <p>Now, this test <strong>does not fail</strong> and everything is working as it should, but PHPUnit still displays the following types of errors:</p>
  
  <pre><code>[error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: "Access Denied by controller annotation @IsGranted("ROLE_ADMIN")" at /var/www/symfony/vendor/symfony/security/Http/Firewall/ExceptionListener.php line 117
  </code></pre>
  
  <p>While that doesn't affect the tests per se, as they still succeed, it is still rather bothering as these messages disrupt the output of the test run, making it harder to spot where actual errors occur. Ergo, I'd like to turn off these error messages. IMO, these Exceptions shouldn't be "uncaught", as they're evidently handled by some kind of handler, since they're converted to a JSON response.</p>
  
  <p>What I've tried:  </p>
  
  <ul>
  <li>turning off error logging as mentioned in <a href="https://github.com/symfony/symfony/issues/25311#issuecomment-349290689" rel="noreferrer">this issue</a> describing exactly the behaviour I'm seeing  </li>
  <li>asserting a thrown Exception in PHPUnit, but this fails as the Exception is not actually thrown within the test  </li>
  <li>various PHPUnit settings (<code>error_reporting</code>, <code>SHELL_VERBOSITY</code>, <code>APP_DEBUG</code>, etc)</li>
  </ul>
  
  <p>What I've noticed:</p>
  
  <p>This only happens when the exception is thrown (e.g. due to use of <code>@IsGranted</code>). If I <em>return</em> the exception instead, PHPUnit does not show an error.</p>