代码错误:调用未定义的方法Exception :: getStatusCode()

时间:2015-10-20 00:50:06

标签: php laravel-5.1 codeception

当我在Laravel中的Codeception中运行功能测试时,我偶尔会收到错误:

 [Symfony\Component\Debug\Exception\FatalErrorException]  
  Call to undefined method Exception::getStatusCode() 

这些是我的配置:

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=127.0.0.1;port=3306;dbname=la51'
            user: 'root'
            password: 'root'
            populate: false
            cleanup: false
            reconnect: true

functional.suite.yml

class_name: FunctionalTester
modules:
    enabled:
        # add framework module here
        - \Helper\Functional
        - Asserts
        - Db
        - Laravel5
    config:
        Laravel5:
            cleanup: false

这是我在“codecept run”时在终端中得到的:

Rubens-MacBook-Pro:la51 rubenbijker$ codecept run -vvv
Codeception PHP Testing Framework v2.1.3
Powered by PHPUnit 4.8.10 by Sebastian Bergmann and contributors.

Acceptance Tests (0) ------------------------
Modules: PhpBrowser, \Helper\Acceptance
---------------------------------------------
---------------------------------------------

Functional Tests (9) -------------------------------------------------------------------------------------------------------------------------------
Modules: \Helper\Functional, Asserts, Db, Laravel5
----------------------------------------------------------------------------------------------------------------------------------------------------
Create a boat (AdminCreatesBoatCept)
Scenario:
* As an a guest
* I am on page ""


  [Symfony\Component\Debug\Exception\FatalErrorException]  
  Call to undefined method Exception::getStatusCode()      



  [Symfony\Component\Debug\Exception\FatalErrorException]  
  Call to undefined method Exception::getStatusCode()      


FATAL ERROR. TESTS NOT FINISHED.
Call to undefined method Exception::getStatusCode() 
in /Applications/MAMP/htdocs/la51/app/Exceptions/Handler.php:71
Rubens-MacBook-Pro:la51 rubenbijker$ 

我报告了Codeception的问题,但他们说这是一个Laravel错误,所以他们无法帮助我。 这是因为我的代码中的错误导致的吗?或者是Codeception和Laravel之间的错误配置?

1 个答案:

答案 0 :(得分:3)

问题与Codeception本身无关。它看起来像是您手动编辑了Handler.php文件。您必须修改更改中的错误(调用未定义的方法非常清楚)或将其还原为其原始状态。