title: PHP ZF2 Unit Tests dispatch method very slow
body: <p>I need to test a big site written in ZF2. There is 443 test and about 10000 assertions. Testing with code coverage takes 6 hours!
  I think I found the problem: In controller's tests I use a dispatch method from AbstractHttpControllerTestCase. Time of execution of dispatch method is increasing after each test (from fractions of second to tens of seconds).</p>
  
  <p>I use ZF 2.1.3, PHPUnit 3.7, PHP_CodeCoverage 1.2, Xdebug v2.2.1, PHP 5.4.7.</p>
  
  <p>My dispatch method:</p>
  
  <pre><code>public function dispatch($url, $method = HttpRequest::METHOD_GET, $params = array())
  {
      $s = microtime(true);
  
      parent::dispatch($url, $method, $params);
  
      $end = microtime(true) - $s;
      echo 'dis: '.$end."\n";
  
      return $this-&gt;getApplication()-&gt;getMvcEvent()-&gt;getResult();
  }
  </code></pre>
  
  <p>parent::dispatch is method from AbstractHttpControllerTestCase.</p>
  
  <p>Sample of test:</p>
  
  <pre><code>$result = $this-&gt;dispatch('/archive/finance/older');
  
  $this-&gt;assertControllerName('skycontent\controller\article');
  $this-&gt;assertActionName('archive');
  $this-&gt;assertParamValue('older', true);
  $this-&gt;assertParamValue('category', 'finance');
  
  $vars = (array) $result-&gt;getVariables();
  
  $this-&gt;assertArrayHasKey('archivePosts', $vars);
  </code></pre>
  
  <p>Please help.
  Thanks.</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>I use process isolation and tests done in about 15 minutes (without code coverage) but I get error in the test that are marked as skipped:</p>
  
  <pre><code>PHPUnit_Framework_Exception: PHP Fatal error:  Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in -:44
  </code></pre>