Throw an exception if the bundle isn't registered
This commit is contained in:
@@ -20,6 +20,7 @@ use Behat\Testwork\Environment\Exception\EnvironmentIsolationException;
|
|||||||
use Behat\Testwork\Environment\Handler\EnvironmentHandler;
|
use Behat\Testwork\Environment\Handler\EnvironmentHandler;
|
||||||
use Behat\Testwork\Suite\Exception\SuiteConfigurationException;
|
use Behat\Testwork\Suite\Exception\SuiteConfigurationException;
|
||||||
use Behat\Testwork\Suite\Suite;
|
use Behat\Testwork\Suite\Suite;
|
||||||
|
use FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle;
|
||||||
use FriendsOfBehat\SymfonyExtension\Context\Environment\InitialisedContextServiceEnvironment;
|
use FriendsOfBehat\SymfonyExtension\Context\Environment\InitialisedContextServiceEnvironment;
|
||||||
use FriendsOfBehat\SymfonyExtension\Context\Environment\UninitialisedContextServiceEnvironment;
|
use FriendsOfBehat\SymfonyExtension\Context\Environment\UninitialisedContextServiceEnvironment;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
@@ -155,6 +156,18 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler
|
|||||||
|
|
||||||
private function getContainer(): ContainerInterface
|
private function getContainer(): ContainerInterface
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
$this->symfonyKernel->getBundle('FriendsOfBehatSymfonyExtensionBundle');
|
||||||
|
} catch (\InvalidArgumentException $exception) {
|
||||||
|
throw new \DomainException(sprintf(
|
||||||
|
'Kernel "%s" used in Behat in "%s" environment with debug %s needs to have "%s" bundle registered.',
|
||||||
|
get_class($this->symfonyKernel),
|
||||||
|
$this->symfonyKernel->getEnvironment(),
|
||||||
|
$this->symfonyKernel->isDebug() ? 'enabled' : 'disabled',
|
||||||
|
FriendsOfBehatSymfonyExtensionBundle::class
|
||||||
|
), 0, $exception);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->symfonyKernel->getContainer();
|
return $this->symfonyKernel->getContainer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace FriendsOfBehat\SymfonyExtension\ServiceContainer;
|
namespace FriendsOfBehat\SymfonyExtension\ServiceContainer;
|
||||||
|
|
||||||
use Behat\Behat\Context\ServiceContainer\ContextExtension;
|
use Behat\Behat\Context\ServiceContainer\ContextExtension;
|
||||||
use Behat\Mink\Mink;
|
|
||||||
use Behat\Mink\Session;
|
use Behat\Mink\Session;
|
||||||
use Behat\MinkExtension\ServiceContainer\MinkExtension;
|
use Behat\MinkExtension\ServiceContainer\MinkExtension;
|
||||||
use Behat\Testwork\Environment\ServiceContainer\EnvironmentExtension;
|
use Behat\Testwork\Environment\ServiceContainer\EnvironmentExtension;
|
||||||
|
|||||||
Reference in New Issue
Block a user