Skip to content

source_dir is not really project_dir #182

@flohw

Description

@flohw

Hi,

I come across an error which was not impactful for me until now...

The documentation says that $browser->saveSource('file') will save into <project-dir>/var/browser/source by default or BROWSER_SOURCE_DIR. The former is fine to me but does not actually works... It saves into ./var/browser/source, which is not the same.

I have a monorepo project with an agular client in client directory and a Symfony backend into server directory. My tests are under server/tests/.

When running my test with my cli (with docker) I use docker compose exec -w /symfony/server php bin/phpunit <path to test>, everything works as expected and my file is stored in %kernel.project_dir%/var/browser/source.
But for a reason I don't quiet understand fully, when I run the test into PHPStorm, the cwd is /symfony instead of %kernel.project_dir%.

To clarify a bit: %kernel.project_dir% is /home/user/project/server on my local machine but /symfony/server inside the docker container.

Inside the saveSource method, the current directory is /symfony/server and the default path works as expected when running through my cli with the -w docker option. But is /symfony while running through phpstorm.

As this is the only case which is erroneous and the kernel.project_dir is not explicitly mentioned, I doubt it comes from my configuration (we can run the bin/console from anywhere and kernel.project_dir is always the symfony project root dir (/symfony/server in my case).

I know where to fix the issue, but I don't know how as I don't have access to the getContainer method as the class does not depend on symfony test environment. I can provide a path if you can provide me some info.

After writing all this, maybe <project-dir> is not meant to be %kernel.project_dir% and all the issue is not relevant, but providing the real default source path may make things clearer. 🤔

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