Problem/Motivation

I'm having an issue running behat tests using api_driver: 'Drupal'.
I made a behat-drupal-extension system wide installation by following the documentation.
Think I meet the system requirements.

My environment:

drupal/core: 9.2.13,
drupal/drupal-extension: 4.1,
behat/behat: 3.10.0,
behat/mink: 1.9.0,
behat/mink-extension: 2.3.1,
This configuration uses
symfony/console v5.4.5
According to symfony/console changelog @ https://github.com/symfony/console/blob/master/CHANGELOG.md
symfony/console v5.3 Adds InputOption::VALUE_NEGATABLE flag to handle --foo/--no-foo options.
I really don't know if this has something to do with the issue I'm having.

The issue:

Fatal error: Uncaught Error: Call to undefined method Symfony\Component\Console\Input\InputOption::isNegatable() in /opt/drupalextension/vendor/symfony/console/Input/InputDefinition.php:253
Stack trace:
#0 /Users/userName/sites/projectRoot/vendor/symfony/console/Command/Command.php(409): Symfony\Component\Console\Input\InputDefinition->addOption(Object(Symfony\Component\Console\Input\InputOption))
#1 /Users/userName/sites/projectRoot/vendor/behat/behat/src/Behat/Testwork/Suite/Cli/SuiteController.php(55): Symfony\Component\Console\Command\Command->addOption('--suite', '-s', 2, 'Only execute a ...')
#2 /Users/userName/sites/projectRoot/vendor/behat/behat/src/Behat/Testwork/Cli/Command.php(48): Behat\Testwork\Suite\Cli\SuiteController->configure(Object(Behat\Testwork\Cli\Command))
#3 /Users/userName/sites/projectRoot/vendor/symfony/console/Command in /opt/drupalextension/vendor/symfony/console/Input/InputDefinition.php on line 253
salifutraore@salifus-mbp behat %

Below is my behat.yml file

default:
  autoload:
    '': "%paths.base%/../../web/profiles/contrib/social/tests/behat/features/bootstrap"
  suites:
    default:
      parameters:
        test_users:
          admin:
            username: 'admin'
            password: 'admin'
            mail: 'info+admin@example.com'
      paths:
        features: "%paths.base%/../../web/profiles/contrib/social/tests/behat/features"
        bootstrap: "%paths.base%/../../web/profiles/contrib/social/tests/behat/features/bootstrap"
      contexts:
        - Drupal\social\Behat\FeatureContext
        - Drupal\social\Behat\SocialDrupalContext
        - Drupal\social\Behat\SocialMessageContext
        - Drupal\social\Behat\SocialMinkContext
        - Drupal\DrupalExtension\Context\BatchContext
        - Drupal\DrupalExtension\Context\ConfigContext
        - Drupal\social\Behat\PostContext
        - Drupal\social\Behat\EmailContext
  extensions:
      Drupal\MinkExtension:
        default_session: 'selenium2'
        base_url: 'http://localhost'
        files_path: '/root/files/'
        goutte: ~
        selenium2:
          wd_host: 'http://selenium:4444/wd/hub/'
          browser: 'firefox'
      Drupal\DrupalExtension:
        drush:
          alias: '@self'
        blackbox: ~
        api_driver: 'drupal'
        drupal:
          drupal_root: '/Users/myUserName/sites/myProjectRoot/web'

        ----

The blackbox: ~ alone works when I run the tests with extensions configuration below:

default:
  ---
  extensions:
      Drupal\MinkExtension:
        default_session: 'selenium2'
        base_url: 'http://localhost'
        files_path: '/root/files/'
        goutte: ~
        selenium2:
          wd_host: 'http://selenium:4444/wd/hub/'
          browser: 'firefox'
      Drupal\DrupalExtension:
        drush:
          alias: '@self'
        blackbox: ~
        ----

Thank you for your help.

Comments

Salif created an issue. See original summary.

reshma_n’s picture

We are facing the same error.

Salif’s picture

I Managed to solve this issue by requiring symfony/console 4.4 in my composer.json as per drupal 9.2.13 requirement in my project. otherwise, the composer.json with drupal/drupal-extension 4.1 alone will download symfony/console 5.4.5 which throws this error in my use case.

Below is the composer.json that worked for me.

{
  "require": {
    "drupal/drupal-extension": "^4.1",
    "symfony/yaml": "^4.4",
    "symfony/event-dispatcher": "^4.4",
    "symfony/console": "^4.4"
  },
  "config": {
    "bin-dir": "bin/"
  }
}

I followed the Behat Drupal Extension system-wide installation documentation at https://behat-drupal-extension.readthedocs.io/en/latest/globalinstall.html

benlakaz’s picture

Hi Salif,
Does this work with PHP 7 only?
The below problem appeared when we tried the symfony/console 4.4

Problem 1
- Root composer.json requires symfony/yaml 4.4 -> satisfiable by symfony/yaml[v4.4.0].
- symfony/yaml v4.4.0 requires php ^7.1.3 -> your php version (8.0.17) does not satisfy that requirement.
Problem 2
- Root composer.json requires symfony/event-dispatcher 4.4 -> satisfiable by symfony/event-dispatcher[v4.4.0].
- symfony/event-dispatcher v4.4.0 requires php ^7.1.3 -> your php version (8.0.17) does not satisfy that requirement.
Problem 3
- Root composer.json requires symfony/console 4.4 -> satisfiable by symfony/console[v4.4.0].
- symfony/console v4.4.0 requires php ^7.1.3 -> your php version (8.0.17) does not satisfy that requirement.
Problem 4
- symfony/console v4.4.0 requires php ^7.1.3 -> your php version (8.0.17) does not satisfy that requirement.
- behat/behat v3.10.0 requires symfony/console ^4.4 || ^5.0 || ^6.0 -> satisfiable by symfony/console[v4.4.0].
- Root composer.json requires behat/behat v3.10.0 -> satisfiable by behat/behat[v3.10.0].

Salif’s picture

@Benlakaz,
By the time I've fixed the issue, my project was Drupal 9.2.13 and PHP ^7.4 versions. Unfortunately I haven't tried PHP ^8 yet.

alex.skrypnyk’s picture

Status: Active » Fixed

This should be resolved in the latest version.
https://github.com/jhedstrom/drupalextension/releases/tag/v5.2.0

Please re-open in GitHub.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.