0

我们在 CakePHP 2.6.x 应用程序中设置了 PHPUnit 测试设置,但每次运行示例测试时 testAction 都会抛出此错误:

UsersControllerTest::testLogin
Undefined index: SERVER_PORT

对于这个单元测试:

public function testLogin()
{
    $result = $this->testAction( '/users/login' );

    ...

    debug( $result );
}

有谁知道错过了什么?正在测试的文档中没有提到 SERVER_PORT。

4

1 回答 1

0

某些组件(来自 CakePHP 或您的)正在使用此属性,并且在从 CLI 运行时未设置它。

您可以在失败测试的 setUp 方法中手动设置它。

于 2015-06-29T12:09:21.357 回答