Skip to content

Commit

Permalink
minor #314 [Maintenance] Enable symfony workflow tests (Wojdylak)
Browse files Browse the repository at this point in the history
This PR was merged into the main branch.

Discussion
----------



Commits
-------

dbbc1e6 [Maintenance] Enable symfony workflow tests
  • Loading branch information
GSadee committed Apr 3, 2024
2 parents 0bf3e7c + dbbc1e6 commit f988ceb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
6 changes: 0 additions & 6 deletions tests/Application/config/sylius/1.13/_sylius.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions tests/Application/config/sylius/1.13/packages/_sylius.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
parameters:
test_default_state_machine_adapter: 'symfony_workflow'
test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%'

sylius_state_machine_abstraction:
graphs_to_adapters_mapping:
sylius_payment: '%test_sylius_state_machine_adapter%'
default_adapter: '%test_sylius_state_machine_adapter%'
40 changes: 40 additions & 0 deletions tests/Application/src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
Expand All @@ -21,12 +23,15 @@
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Config\FileLocator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Webmozart\Assert\Assert;

final class Kernel extends BaseKernel
{
use MicroKernelTrait;

private const CONFIG_EXTS = '.{php,xml,yaml,yml}';

public function getCacheDir(): string
{
return $this->getProjectDir() . '/var/cache/' . $this->environment;
Expand All @@ -44,6 +49,26 @@ public function registerBundles(): iterable
}
}

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
foreach ($this->getBundleListFiles() as $file) {
$container->addResource(new FileResource($file));
}

$container->setParameter('container.dumper.inline_class_loader', true);

foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadContainerConfiguration($loader, $confDir);
}
}

protected function configureRoutes(RoutingConfigurator $routes): void
{
foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadRoutesConfiguration($routes, $confDir);
}
}

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment() && class_exists(MockerContainer::class)) {
Expand Down Expand Up @@ -75,6 +100,21 @@ private function isTestEnvironment(): bool
return str_starts_with($this->getEnvironment(), 'test');
}

private function loadContainerConfiguration(LoaderInterface $loader, string $confDir): void
{
$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
}

private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void
{
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS);
}

/**
* @return BundleInterface[]
*/
Expand Down

0 comments on commit f988ceb

Please sign in to comment.