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

IBX-3451: [Behat] Removed depending on APP_ENV when loading Context services #324

Merged
merged 2 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ public function load(array $configs, ContainerBuilder $container)

$configuration = $this->getConfiguration($configs, $container);

$environment = $container->getParameter('kernel.environment');
if (in_array($environment, ['behat', 'test'])) {
if ($this->shouldLoadTestServices($container)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I see it, I think it should be a separate bundle, not a part of Core ;)

$loader->load('feature_contexts.yml');
}

Expand Down Expand Up @@ -668,4 +667,10 @@ private function registerForAutoConfiguration(ContainerBuilder $container): void
$container->registerForAutoconfiguration(FilteringSortClauseQueryBuilder::class)
->addTag(ServiceTags::FILTERING_SORT_CLAUSE_QUERY_BUILDER);
}

private function shouldLoadTestServices(ContainerBuilder $container): bool
{
return $container->hasParameter('ibexa.testing.browser.enabled')
&& true === $container->getParameter('ibexa.testing.browser.enabled');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Configuration\Parser\Content;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension;
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\ServiceTags;
use eZ\Bundle\EzPublishCoreBundle\Features\Context\QueryControllerContext;
use eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Stub\Filter\CustomCriterionQueryBuilder;
use eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Stub\Filter\CustomSortClauseQueryBuilder;
use eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Stub\QueryTypeBundle\QueryType\TestQueryType;
Expand Down Expand Up @@ -853,6 +854,19 @@ public function getFilteringQueryBuilderData(): iterable
];
}

public function testDoesNotLoadTestServicesByDefault(): void
{
$this->load();
$this->assertContainerBuilderNotHasService(QueryControllerContext::class);
}

public function testLoadsTestServicesWhenParameterIsSpecified(): void
{
$this->container->setParameter('ibexa.testing.browser.enabled', true);
$this->load();
$this->assertContainerBuilderHasService(QueryControllerContext::class);
}

/**
* Prepare Core Container for compilation by mocking required parameters and compile it.
*/
Expand Down