1
我試圖在Codeception運行測試,以測試我的API生成使用Laravel 5.當我裝PhpBrowser
作爲依賴於REST
,它工作正常,但是當我把它轉移到Laravel5
,我得到一個奇怪的錯誤說:在laravel 5的代碼測試調用中造成如此之多的嵌套?
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' => '[email protected]',
'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);
我在做什麼錯?