2

我有一个 RESTful API,我想使用 codeception 进行测试。用于代码接收的 REST 模块似乎无法检索响应代码和内容。

这是完整的堆栈跟踪:

$ ./vendor/codeception/codeception/codecept run --debug Codeception PHP Testing Framework v1.8.0-dev Powered by PHPUnit 3.7.28 by Sebastian Bergmann.

Acceptance Tests (0) ------------------------ Modules: PhpBrowser, WebHelper
---------------------------------------------
---------------------------------------------

Api Tests (1)
--------------------------------------------------------------------- Modules: PhpBrowser, WebHelper, REST, ApiHelper, Laravel4
----------------------------------------------------------------------------------- Trying to verify that i can retrieve a vehicle (GetVehicleInfoCept.php)        Scenario:
* I am http authenticated "root","root"
* I send get "v1/voertuigen/62jtvg",   [Request] GET http://imac-van-maarten.local/voertuiginformatiemodule/public/v1/voertuigen/62jtvg [Response] {"provider":"A2SP","kenteken":"62JTVG","merk":"Seat","model":"IBIZA","primaire_kleur":"GRIJS","uitvoering_id":"241757001936","eerste_toelating":"20020828","laatste_tenaamstelling":"20130204","primaire_brandstof":"benzine"} [Headers] {"date":["Thu, 31 Oct 2013 09:00:28 GMT"],"server":["Apache\/2.2.23 (Unix) mod_ssl\/2.2.23 OpenSSL\/0.9.8y DAV\/2 PHP\/5.4.10"],"x-powered-by":["PHP\/5.4.10"],"set-cookie":["laravel_session=7427bb97beee80b7abcf2a632ba9ecf7; expires=Thu, 31-Oct-2013 11:00:28 GMT; path=\/; HttpOnly","laravel_session=7427bb97beee80b7abcf2a632ba9ecf7; expires=Thu, 31-Oct-2013 11:00:28 GMT; path=\/; httponly"],"cache-control":["no-cache"],"transfer-encoding":["chunked"],"content-type":["application\/json"]} [Status] 200
* I see response is json 
* I see response code is 200  FAIL 

-----------------------------------------------------------------------------------

Functional Tests (0) ------------------------ Modules: Filesystem, TestHelper, Laravel4
---------------------------------------------
---------------------------------------------

Unit Tests (0) ------------------------------ Modules: CodeHelper
---------------------------------------------
---------------------------------------------


Time: 464 ms, Memory: 18.25Mb

There was 1 failure:

--------- 1) Failed to verify that i can retrieve a vehicle in GetVehicleInfoCept.php Sorry, I couldn't see response code is 200: Failed asserting that 'N/A' matches expected 200.

Scenario Steps:
4. I see response code is 200
3. I see response is json 
2. I send get "v1/voertuigen/62jtvg",
1. I am http authenticated "root","root"


FAILURES! Tests: 1, Assertions: 2, Failures: 1.

显然响应代码是 200,但不知何故它无法检索响应代码。这里发生了什么?

4

0 回答 0