是什么导致我在 laravel 5 中的 codeception 测试调用中出现如此多的嵌套?

What is causing so much nesting in my codeception test call in laravel 5?

我正在尝试 运行 在 Codeception 中进行测试,以测试我使用 Laravel 5 构建的 API。当我加载 PhpBrowser 作为 REST 的依赖项时,它工作正常但是当我将它转移到 Laravel5 时,我收到一个奇怪的错误:

Maximum function nesting level of '100' reached, aborting!

我上网查了一下,解决方法是编辑php.ini文件,增加嵌套的限制。所以我将这一行添加到我的 php.ini:

xdebug.max_nesting_level = 200

并重新启动我的服务器:

sudo service apache2 restart

然而,当我尝试 运行 我的测试时,我遇到了同样的错误。我的 **codeception.yml** 文件如下所示:

actor: Tester
paths:
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
settings:
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
extensions:
    enabled:
        - Codeception\Extension\RunFailed
modules:
    config:
        Db:
            dsn: 'mysql:host=localhost;dbname=carparts'
            user: 'root'
            password: 'admin12345'
            dump: tests/_data/dump.sql

我的 **api.suite.yml** 文件如下所示:

class_name: ApiTester
modules:
    enabled:
        - Laravel5
        - REST:
            url: http://localhost:8000/api/
            depends: Laravel5
    config:
        Laravel5:
            cleanup: true
            environment_file: .env.testing

我的测试是这样的:

<?php
$I = new ApiTester($scenario);
$I->wantTo('authenticate a user');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('authenticate', [
    'username' => 'carparts',
    'email' => 'admin@admin.com',
    'password' => 'password'
]);
$I->seeResponseCodeIs(200);
$I->seeResponseIsJson();

// Storing a token temporarily to run further tests
$response = $I->grabResponse();
file_put_contents('tests/api/token', json_decode($response)->token);

我做错了什么?

翻了几个论坛,终于找到了thisrogierverbrugge 准确无误。

所以我毕竟试图编辑错误的文件。我不得不编辑 /etc/php5/mods-available/xdebug.ini 并添加:

xdebug.max_nesting_level=500

现在我的测试非常有效。 :)