使用Yii2的Codeception的see()方法不会显示页面的全部内容

时间:2018-05-22 21:06:31

标签: testing yii2 phpstorm bdd codeception

我正在测试使用Yii2框架的PHP(7.2.1)系统,为此,我默认使用代码。

编写功能测试时,有几种方法无法按预期工作。其中有see()方法,它应该获取在指定页面上作为参数传递的文本。在我的例子中,see()方法只搜索应用程序的侧面菜单,而不是整个页面。

我想帮助尝试解决此错误,我已经研究过该框架的文档,但找不到与我的问题相关的任何内容。

这是我编写的功能测试的代码和显示的错误。

测试类:

<?php

use app\models\Usuario;

class FirstTryLoginCest
{

    public function _before(\FunctionalTester $I)
    {
        $I->amOnRoute('site/login');
    }

    public function submitFormSuccessfully(\FunctionalTester $I)
    {
        $I->submitForm('#login-form', [
            '#usuario-username' => 'Fulano',
            '#usuario-password' => '12345678'
        ]);
        $I->see('Mural');
    }

    public function internalLoginByInstance(\FunctionalTester $I)
    {
        $admin = \app\models\Usuario::findOne(33);
        $I->amLoggedInAs($admin);
        $I->amOnPage('gestor/mural');
        $I->see('Fulano');
    }

}

显示错误:

Codeception PHP Testing Framework v2.4.1
Powered by PHPUnit 7.1.5 by Sebastian Bergmann and contributors.

Functional Tests (2) -------------------------------------------------- 
✖ FirstTryLoginCest: Submit form successfully (0.14s)
✖ FirstTryLoginCest: Internal login by instance (0.07s)
----------------------------------------------------------------------- 

Unit Tests (0) -------------------------------------------------------- 
----------------------------------------------------------------------- 

Time: 464 ms, Memory: 16.00MB

There were 2 failures:

---------
1) FirstTryLoginCest: Submit form successfully
Test  tests/functional/FirstTryLoginCest.php:submitFormSuccessfully
Step  See "Mural"
Fail  Failed asserting that  on page /index-test.php?r=site%2Flogin
-->  Username cannot be blank. Password cannot be blank. Lembrar no 
próximo acesso Entrar Esqueci minha senha Copyright &COPY; 2018 Nome da 
empresa 
--> contains "Mural".

Scenario Steps:

3. $I->see("Mural") at tests/functional/FirstTryLoginCest.php:19
2. $I->submitForm("#login-form",{"#usuario- 
username":"Fulano","#usuario-password":"12345678"}) at 
tests/functional/FirstTryLoginCest.php:16
1. $I->amOnRoute("site/login") at 
tests/functional/FirstTryLoginCest.php:10


---------
2) FirstTryLoginCest: Internal login by instance
Test  tests/functional/FirstTryLoginCest.php:internalLoginByInstance
Step  See "Fulano"
Fail  Failed asserting that  on page /gestor/mural
-->  Toggle navigation Fulano Fulano Fulaninho Administrador 
Perfil Sair Fulano Gii Debug Same tools Gii Debug Level One Level Two 
Level Two Level Three Level Three Nome da empresa &COPY; 2018   Nome da 
empresa Software Versão 9.0 β string(1) "0" 
--> contains "Fulano".

Scenario Steps:

4. $I->see("Fulano") at tests/functional/FirstTryLoginCest.php:29
3. $I->amOnPage("gestor/mural") at 
tests/functional/FirstTryLoginCest.php:28

提前致谢!

0 个答案:

没有答案