我正试图在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);
我做错了什么?
在浏览了许多论坛后,我终于发现了这一点。rogierverbrugge
在上
所以我试图编辑错误的文件。我不得不编辑/etc/php5/mods-available/xdebug.ini
并添加:
xdebug.max_nesting_level=500
我的测试现在很有魅力