Tests with codeception

hi! When executing the command: ./vendor/bin/codecept run in my project, the following error occurs: “[yii\base\ErrorException] The use statement with non-compound name ‘Yii’ has no effect” . This only occurs in FUNCTIONAL TESTS, followed the test code:

<?php

namespace app\tests\acceptance;


use AcceptanceTester;

class ClassesOperacoesACCCest
{

    public function _before(AcceptanceTester $I)
    {

        $I->amOnPage('/site/login');
        $I->fillField(['name' => 'LoginForm[username]'], 'admin');
        $I->fillField(['name' => 'LoginForm[password]'], 'admin');
        $I->click('Acessar');
    }
    public function testCriaNovaClasse(AcceptanceTester $I)
    {

       

        $I->amOnPage('/config/classes-operacoes/create');
       

        $I->see("Cria Classes Operacoes");

    }
}

confg. functional.suite.yml:


class_name: FunctionalTester
modules:
  enabled:
    - Filesystem
    - Asserts
    - Yii2

The error occurs when executing the line: $I->click(‘Acessar’). I would like to know if anyone knows the reason for this error ?

Please post full stack trace

1 Like

followed the stack error:

1) ClassesOperacoesACCCest: Test cria nova classe
 Test  tests/functional/ClassesOperacoesAccCest.php:testCriaNovaClasse
                                                                                          
  [yii\base\ErrorException] The use statement with non-compound name 'Yii' has no effect  
                                                                                          

Scenario Steps:

 4. $I->click("Acessar") at tests/functional/ClassesOperacoesAccCest.php:17
 3. $I->fillField({"name":"LoginForm[password]"},"admin") at tests/functional/ClassesOperacoesAccCest.php:16
 2. $I->fillField({"name":"LoginForm[username]"},"admin") at tests/functional/ClassesOperacoesAccCest.php:15
 1. $I->amOnPage("/site/login") at tests/functional/ClassesOperacoesAccCest.php:14

#1  /var/www/lib/componentes/hail812/yii2-adminlte3/src/views/layouts/content.php:4
#2  /var/www/vendor/yiisoft/yii2/base/View.php:347
#3  /var/www/vendor/yiisoft/yii2/base/View.php:347
#4  /var/www/vendor/yiisoft/yii2/base/View.php:257
#5  /var/www/vendor/yiisoft/yii2/base/View.php:156
#6  /var/www/lib/componentes/hail812/yii2-adminlte3/src/views/layouts/main.php:79
#7  /var/www/vendor/yiisoft/yii2/base/View.php:347
#8  /var/www/vendor/yiisoft/yii2/base/View.php:257
#9  /var/www/vendor/yiisoft/yii2/base/Controller.php:422
#10 /var/www/vendor/yiisoft/yii2/base/Controller.php:408
Artifacts:

Solved, just remove the “use Yii;” from the file: " /var/www/lib/components/hail812/yii2-adminlte3/src/views/layouts/content.php"