对代码接收的功能测试不起作用

时间:2018-09-20 12:38:20

标签: php codeception

我有以下代码:

class FirstCest
{
    public function _before(FunctionalTester $I)
    {
    }

    public function _after(FunctionalTester $I)
    {
    }

    public function tryToTest(FunctionalTester $I)
    {               
        $I->amOnPage('/about');
    }
}

这是我的配置:

actor: FunctionalTester
modules:
    enabled:
        - \Helper\Functional
error_level: "E_ALL"

当我尝试运行时:tests/functional/FirstCest.php:tryToTest我得到:

  

[RuntimeException]调用未定义的方法   FunctionalTester :: amOnPage

1 个答案:

答案 0 :(得分:2)

编写您自己的模块或使用PhpBrowser。 我看到您已经开始在https://github.com/visavi/codeception-phpixie/上工作。

缺少的一个明显的东西是连接器类。 示例:https://github.com/Codeception/Codeception/blob/2.4.5/src/Codeception/Lib/Connector/Guzzle6.php#L183-L217

Connector类必须扩展BrowserKit \ Client类(除非您的框架基于Symfony Http组件,在这种情况下,请查看Symfony模块和连接器的代码)。 并实现doRequest方法,该方法将BrowserKit \ Request对象转换为框架所需的对象,并调用框架代码并将框架响应转换为BrowserKit \ Response。

doRequest方法的中间部分必须基于您放置在站点的index.php中的代码。

在评论中提问。