Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension sets Definition->file to root-dir #154

Open
leberknecht opened this issue Dec 10, 2019 · 0 comments
Open

Extension sets Definition->file to root-dir #154

leberknecht opened this issue Dec 10, 2019 · 0 comments

Comments

@leberknecht
Copy link

I upgraded my api-platform project from 2.4.2 to 2.5.3, im not exactly sure where the different behavior from the behat-extension comes from, but i found that: on the older version, the environment on vendor/behat/symfony2-extension/src/Behat/Symfony2Extension/ServiceContainer/Symfony2Extension.php:process looks like this:

$basePath = "/home/delf/<project>/api"
$bootstrap = "/home/delf/<project>/api/tests/features/bootstrap/bootstrap.php"
$bootstrapPath = "tests/features/bootstrap/bootstrap.php"
$container = {Symfony\Component\DependencyInjection\ContainerBuilder} [33]
$kernelPath = "app/AppKernel.php"

while after the upgrade it is this:

$basePath = "/home/delf/dev/efi/api"
$bootstrapPath = null
$container = {Symfony\Component\DependencyInjection\ContainerBuilder} [33]
$kernelPath = null

then we do on Symfony2Extension.php:138

if (file_exists($kernel = $basePath . '/' . $kernelPath)) 

which will be true, as the concatenated string points to a directory and file_exists treats files and directories the same. If we would trigger the other if-branch, we would set just $kernelPath (null) to Definition->file (and i think that would actually work on createService later on..?)
So, question: i'm not quite sure about that, but shouldnt we use

if (file_exists($kernel = $basePath . '/' . $kernelPath) && is_file($kernel))

instead, to ensure that we are pointing to a file and not a directory?

Site-note, if someone else runs into this: just set the path on the extension definition:

    extensions:
        Behat\Symfony2Extension:
            kernel:
                bootstrap: "tests/features/bootstrap/bootstrap.php"
                class: App\Kernel
                path: "app/AppKernel.php"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant