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

Can't use %paths.base% inside extensions: Failed opening required '%paths.base%' #1455

Open
tomasvts opened this issue Jan 10, 2024 · 2 comments

Comments

@tomasvts
Copy link

tomasvts commented Jan 10, 2024

Edit: #1455 (comment)

Hello,

This is my configuration

workspace/project/behat.yml.dist

default:
    gherkin:
        filters:
            tags: ~oauth
    calls:
        error_reporting: 16383 # E_ALL & ~E_USER_DEPRECATED
    autoload:
        '': '%paths.base%/tests/Functional/Bootstrap'
    extensions:
        FriendsOfBehat\SymfonyExtension:
            bootstrap: '%paths.base%/tests/bootstrap.php'
        rdx\behatvars\BehatVariablesExtension: ~
    suites:
        default:
            paths:
                - '%paths.base%/tests/Functional/Features'
            contexts:
                - rdx\behatvars\BehatVariablesContext
                - App\Tests\Functional\Bootstrap\SetupContext:
                - App\Tests\Functional\Bootstrap\HttpContext:

And when I execute my tests, behat does not compile the configuration, and it does not replace the placeholder %paths.base%.
I've tried with quotes, double quotes, without quotes, and all with no avail. None of them work.

The error is:

/var/www/html # behat
PHP Warning:  require_once(%paths.base%/tests/bootstrap.php): Failed to open stream: No such file or directory in /var/www/html/vendor/friends-of-behat/symfony-extension/src/ServiceContainer/SymfonyExtension.php on line 182
PHP Fatal error:  Uncaught Error: Failed opening required '%paths.base%/tests/bootstrap.php' (include_path='.:/usr/local/lib/php') in /var/www/html/vendor/friends-of-behat/symfony-extension/src/ServiceContainer/SymfonyExtension.php:182
Stack trace:
#0 /var/www/html/vendor/friends-of-behat/symfony-extension/src/ServiceContainer/SymfonyExtension.php(76): FriendsOfBehat\SymfonyExtension\ServiceContainer\SymfonyExtension->loadBootstrap()
#1 /var/www/html/vendor/behat/behat/src/Behat/Testwork/ServiceContainer/ContainerLoader.php(159): FriendsOfBehat\SymfonyExtension\ServiceContainer\SymfonyExtension->load()
#2 /var/www/html/vendor/behat/behat/src/Behat/Testwork/ServiceContainer/ContainerLoader.php(130): Behat\Testwork\ServiceContainer\ContainerLoader->loadExtension()
#3 /var/www/html/vendor/behat/behat/src/Behat/Testwork/ServiceContainer/ContainerLoader.php(67): Behat\Testwork\ServiceContainer\ContainerLoader->loadExtensions()
#4 /var/www/html/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(185): Behat\Testwork\ServiceContainer\ContainerLoader->load()
#5 /var/www/html/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(161): Behat\Testwork\Cli\Application->createContainer()
#6 /var/www/html/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php(122): Behat\Testwork\Cli\Application->createCommand()
#7 /var/www/html/vendor/symfony/console/Application.php(169): Behat\Testwork\Cli\Application->doRun()
#8 /var/www/html/vendor/behat/behat/bin/behat(34): Symfony\Component\Console\Application->run()
#9 /var/www/html/vendor/bin/behat(119): include('...')
#10 {main}
  thrown in /var/www/html/vendor/friends-of-behat/symfony-extension/src/ServiceContainer/SymfonyExtension.php on line 182

I'll remove the %paths.base% placeholders for now, but I believe this is a feature that should work if the documentation says so.

@tomasvts
Copy link
Author

Related
FriendsOfBehat/SymfonyExtension#151

@tomasvts
Copy link
Author

tomasvts commented Jan 11, 2024

Update:
The variable expansion works outside the "extensions" block.
So if I remove paths.base from the extensions block it works:

default:
    gherkin:
        filters:
            tags: ~oauth
    calls:
        error_reporting: 16383 # E_ALL & ~E_USER_DEPRECATED
    autoload:
        '': '%paths.base%/tests/Functional/Bootstrap'
    extensions:
        FriendsOfBehat\SymfonyExtension:
            bootstrap: /full/path/to/my/workspace/folder/tests/bootstrap.php
        rdx\behatvars\BehatVariablesExtension: ~
    suites:
        default:
            paths:
                - '%paths.base%/tests/Functional/Features'
            contexts:
                - rdx\behatvars\BehatVariablesContext
                - App\Tests\Functional\Bootstrap\SetupContext:
                - App\Tests\Functional\Bootstrap\HttpContext:

@tomasvts tomasvts changed the title Can't use %paths.base%: Failed opening required '%paths.base%' Can't use %paths.base% inside extensions: Failed opening required '%paths.base%' Jan 11, 2024
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