Skip to content

Commit

Permalink
Allow to use env variables in Ecotone's Symfony Config (#392)
Browse files Browse the repository at this point in the history
Allow to use env variables in Ecotone config
  • Loading branch information
dgafka authored Oct 17, 2024
1 parent d592e66 commit 7d7fe6e
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/Laravel/tests/Licence/LicenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Ecotone\Modelling\CommandBus;
use Ecotone\Modelling\QueryBus;
use Ecotone\Test\LicenceTesting;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Http\Kernel;
use PHPUnit\Framework\TestCase;
Expand All @@ -22,13 +23,20 @@ final class LicenceTest extends TestCase

public function setUp(): void
{
putenv('LARAVEL_LICENCE_KEY=' . LicenceTesting::VALID_LICENCE);

$app = require __DIR__ . '/bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
$this->app = $app;
$this->queryBus = $app->get(QueryBus::class);
$this->commandBus = $app->get(CommandBus::class);
}

protected function tearDown(): void
{
putenv('LARAVEL_LICENCE_KEY');
}

public function test_triggering_laravel_with_licence_key(): void
{
$this->commandBus->sendWithRouting('sendNotification');
Expand Down
2 changes: 1 addition & 1 deletion packages/Laravel/tests/Licence/config/ecotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
ModulePackageList::LARAVEL_PACKAGE,
ModulePackageList::ASYNCHRONOUS_PACKAGE,
]),
'licenceKey' => Ecotone\Test\LicenceTesting::VALID_LICENCE,
'licenceKey' => env('LARAVEL_LICENCE_KEY'),
];
3 changes: 3 additions & 0 deletions packages/Symfony/DependencyInjection/EcotoneExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Ecotone\SymfonyBundle\DependencyInjection;

use Ecotone\Messaging\Config\Container\Compiler\RegisterInterfaceToCallReferences;
use Ecotone\Messaging\Config\EnvironmentVariable;
use Ecotone\Messaging\Config\MessagingSystemConfiguration;
use Ecotone\Messaging\Config\ModulePackageList;
use Ecotone\Messaging\Config\ServiceCacheConfiguration;
Expand All @@ -15,6 +16,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Component\DependencyInjection\Reference;

/**
Expand All @@ -26,6 +28,7 @@ public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$config = $container->resolveEnvPlaceholders($config, true);

$skippedModules = $config['skippedModulePackageNames'] ?? [];
if (! $config['test']) {
Expand Down
10 changes: 9 additions & 1 deletion packages/Symfony/tests/phpunit/Licence/LicenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Ecotone\Modelling\CommandBus;
use Ecotone\Modelling\QueryBus;
use Ecotone\Test\LicenceTesting;
use PHPUnit\Framework\TestCase;
use Symfony\App\Licence\Configuration\Kernel;

Expand All @@ -21,6 +22,7 @@ final class LicenceTest extends TestCase

public function setUp(): void
{
putenv('SYMFONY_LICENCE_KEY=' . LicenceTesting::VALID_LICENCE);
$kernel = new Kernel('dev', true);
$kernel->boot();
$app = $kernel->getContainer();
Expand All @@ -30,7 +32,13 @@ public function setUp(): void
$this->kernel = $kernel;
}

public function test_using_enterprise_feature(): void
protected function tearDown(): void
{
putenv('SYMFONY_LICENCE_KEY');
}


public function test_triggering_symfony_with_licence_key(): void
{
$this->commandBus->sendWithRouting('sendNotification');

Expand Down
2 changes: 1 addition & 1 deletion packages/Symfony/tests/phpunit/Licence/config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
ModulePackageList::SYMFONY_PACKAGE,
ModulePackageList::ASYNCHRONOUS_PACKAGE,
]),
'licenceKey' => Ecotone\Test\LicenceTesting::VALID_LICENCE,
'licenceKey' => '%env(SYMFONY_LICENCE_KEY)%',
]);

$services = $containerConfigurator->services();
Expand Down

0 comments on commit 7d7fe6e

Please sign in to comment.