phpunit测试中的xdebug嵌套级别和symfony createClient

I created a simple test to check for any broken pages in a section of a site. The data provider reads from a list of pages and serves the url to the test.

The test code is below:

/**
 * @dataProvider urlProvider
 *
 * @param $url
 *
 */
public function testPageIsSuccessful($url)
{
    $client = self::createClient();
    $client->request('GET', $url);

    $crawler = new Crawler($client->getResponse()->getContent());
    $this->assertTrue($client->getResponse()->isSuccessful());
    $body = $crawler->filter('body');
    $this->assertEquals('http://schema.org/WebPage', $body->attr('itemtype'));
}

The test itself works fine, but as the number of pages raised at some point it started to crash. After investigating the issue I discovered that the issue appeared because the xdebug.max_nesting_level was breached.

I also noticed that the speed test works decreases drasticly (from about 1 second to about 30 seconds after about 100 pages) with the number of pages even though the pages are similar and each call itself should take about same time.

Fixing the crash itself is simple: disable xdebug or add ini_set('xdebug.max_nesting_level', -1); in test setUp. But this would not fix the slowdown (at the moment the slowdown is not a big issue but in about 2-3 weeks it may become a serious one).

My issue is... why does nesting level raises? It should be fixed and about 3 or 4.

There should be no persistent elements between each separate test for another url, and even if there would be nothing from that code should add to nesting level.

The createClient function code is below (and comes from symfony WebTestCase):

/**
 * Creates a Client.
 *
 * @param array $options An array of options to pass to the createKernel class
 * @param array $server  An array of server parameters
 *
 * @return Client A Client instance
 */
protected static function createClient(array $options = array(), array $server = array())
{
    static::bootKernel($options);

    $client = static::$kernel->getContainer()->get('test.client');
    $client->setServerParameters($server);

    return $client;
}

At first glance the bootKernel function checks if kernel was already booted so that should not be an issue.

I also checked for pages redirections and was not an issue. Is strictly related to the number of pages regardless on what are those (I added just one page and called it about 100 times and had same problem so I'm sure is not a broken permanent redirect link).

The symfony version I use is 2.7.

EDIT: Also removed and tested without the getContent part and same thing happens... so the problem should be somewhere in the first 2 lines.