acquia / blt-behat

Acquia BLT plugin providing integration with Behat
GNU General Public License v2.0
0 stars 16 forks source link

Call to undefined method League\Container\Definition\Definition::withArgument #15

Closed mikemadison13 closed 2 years ago

mikemadison13 commented 2 years ago

It looks like as part of the recent update(s) to BLT and BLT Behat, the league/container package bumped from 2.5.x to 3.4.x:

  - Upgrading league/container (2.5.0 => 3.4.1)

This is now causing what was a working build to fail with the following output:

Fatal error: Uncaught Error: Call to undefined method League\Container\Definition\Definition::withArgument() in /mnt/tmp/local.prod/source/vendor/acquia/blt-behat/src/Blt/Plugin/Commands/BehatTestCommand.php:31
Stack trace:
#0 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(47): Acquia\BltBehat\Blt\Plugin\Commands\BehatTestCommand->initialize()
#1 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(36): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook()
#2 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php(29): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook()
#3 /mnt/tmp/local.prod/source/vendor/consolidation/annotated-command/src/CommandProcessor.php(145): Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initia in /mnt/tmp/local.prod/source/vendor/acquia/blt-behat/src/Blt/Plugin/Commands/BehatTestCommand.php on line 31

Note this is pretty hard to clock given that the offending code doesn't use the league/container visibly, it's just:

$this->container->add(TestsWizard::class)->withArgument('executor');
mikemadison13 commented 2 years ago

I'm not 100% sure, but it seems like simply updating it to the following fixes the issue:

$this->container->add(TestsWizard::class)->addArgument('executor');
danepowell commented 2 years ago

That won't be backwards compatible though. You'll need to adopt the method of BLT in https://github.com/acquia/blt/pull/4424 to support both versions, or restrict this plugin to just one version via composer.json

mikemadison13 commented 2 years ago

@danepowell it looks like the method in question, usingLegacyContainer is protected so for now I've replicated it here (but obviously it would be nice if BLT had this as a public method so all the plugins didn't have to replicate it).

danepowell commented 2 years ago

I've made usingLegacyContainer() public in BLT HEAD

mikemadison13 commented 2 years ago

@danepowell is it available in only BLT 13? if so, i'll need to update this to constrain to the right versions of BLT.

bkosborne commented 2 years ago

Ran into this today as well. @mikemadison13 I think it was BLT version 13.2.0 that allowed the container to be updated from 2.x to 3.x, so that would be the minimum version to target.

mikemadison13 commented 2 years ago

@danepowell are you comfortable rolling a new branch of this / new release of this that is like a 13.x specific version? or do you want to merge as is?

deepshet commented 2 years ago

Same issue , happened due to an update to consolidation/robo to 3.* which changed leagure/container (because of drush/drush 10.6.2)