Skip to content

Wrong projectRootPath in FunctionalTester #45

@smirnov-e

Description

@smirnov-e

What steps will reproduce the problem?

Create test with functional tester

final class CitiesActionTest extends TestCase
{
    private ?FunctionalTester $tester;

    protected function setUp(): void
    {
        $this->tester = new FunctionalTester();
        $this->tester->bootstrapApplication(); // <-- no arguments
    }

What is the expected result?

Application bootstrapping does not throw errors or warnings.

What do you get instead?

 Test  tests/Functional/Data/CitiesActionTest.php:testSuccess
                                                                                                                                                                 
  [Warning] require_once(//autoload.php): Failed to open stream: No such file or directory at /app/vendor/yiisoft/yii-testing/src/TestApplicationRunner.php:182  
                                                                                                                                                                 
#1  /app/vendor/yiisoft/yii-testing/src/TestApplicationRunner.php:182
#2  /app/vendor/yiisoft/yii-testing/src/TestApplicationRunner.php:182
#3  /app/vendor/yiisoft/yii-testing/src/FunctionalTester.php:75
#4  /app/tests/Functional/Data/CitiesActionTest.php:23
#5  /app/vendor/bin/codecept:119

Additional info

\Yiisoft\Yii\Testing\FunctionalTester::bootstrapApplication without arguments expects application root to be 5 levels higher:

if ($projectRootPath === null) {
      $projectRootPath = dirname(__DIR__, 5);
}

in my case there should be dirname(__DIR__, 4).

Q A
Version dev-master#9f56e05f4b99b
PHP version 8.4
Operating system Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions