Skip to content

Commit

Permalink
Add new configuration configuration_template_path
Browse files Browse the repository at this point in the history
  • Loading branch information
Dumazeau committed Jan 10, 2024
1 parent fd66684 commit d8615e0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
5 changes: 4 additions & 1 deletion tests/Domain/Generator/NewConfigurationGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ final class NewConfigurationGeneratorTest extends TestCase

public function testGeneratorDefaultTemplate(): void
{
$this->configurationAdapterStub->setConfigurationTemplatePath(null);
$this->configurationAdapterStub->setConfigurationPath('/app/tests/Resources/Files/tmp');

$path = ($this->newConfigurationGenerator)();
Expand All @@ -32,6 +31,10 @@ public function testGeneratorDefaultTemplate(): void

public function testGeneratorCustomTemplate(): void
{
/** @var string $projectDir */
$projectDir = $this->parameterBag->get('kernel.project_dir');

$this->configurationAdapterStub->setConfigurationTemplatePath($projectDir . '/tests/Resources/configuration_template.php.txt');
$this->configurationAdapterStub->setConfigurationPath('/app/tests/Resources/Files/tmp');

$path = ($this->newConfigurationGenerator)();
Expand Down
16 changes: 14 additions & 2 deletions tests/Domain/Port/ConfigurationInterfaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@
use RichCongress\TestFramework\TestConfiguration\Annotation\TestConfig;
use RichCongress\TestSuite\TestCase\TestCase;
use RichId\ConfigurationBundle\Domain\Port\ConfigurationInterface;
use RichId\ConfigurationBundle\Tests\Resources\Stub\ConfigurationAdapterStub;

/** @covers \RichId\ConfigurationBundle\Infrastructure\Adapter\ConfigurationAdapter */
#[TestConfig('fixtures')]
final class ConfigurationInterfaceTest extends TestCase
{
public ConfigurationInterface $configuration;

public ConfigurationAdapterStub $configurationAdapterStub;

public function testGetConfigurationNamespace(): void
{
self::assertSame('RichId\ConfigurationBundle\Tests\Resources\Configurations', $this->configuration->getConfigurationNamespace());
Expand All @@ -24,11 +27,20 @@ public function testGetConfigurationPath(): void
self::assertStringContainsString('/tests/Resources/Configurations', $this->configuration->getConfigurationPath());
}

public function testGetConfigurationTemplatePath(): void
public function testGetConfigurationTemplatePathDefaultValue(): void
{
$conf = $this->configuration->getConfigurationTemplatePath();

self::assertNull($conf);
}


public function testGetConfigurationTemplatePathCsutomValue(): void
{
$this->configurationAdapterStub->setConfigurationTemplatePath('/tests/Resources/configuration_template.php.txt');
$conf = $this->configuration->getConfigurationTemplatePath();

self::assertNotNull($conf);
self::assertStringContainsString('/tests/Resources/configuration_template.php.txt', $conf);
self::assertSame('/tests/Resources/configuration_template.php.txt', $conf);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ rich_id_configuration:
configuration_namespace: 'RichId\ConfigurationBundle\Tests\Resources\Configurations'
configuration_path: '%kernel.project_dir%/tests/Resources/Configurations'
automatic_configuration_loader: 'after_migration_executed'
configuration_template_path: '%kernel.project_dir%/tests/Resources/configuration_template.php.txt'
8 changes: 2 additions & 6 deletions tests/Resources/Stub/ConfigurationAdapterStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ public function getConfigurationPath(): string
return $this->innerService->getConfigurationPath();
}

public function getConfigurationTemplatePath(): string
public function getConfigurationTemplatePath(): ?string
{
if ($this->configurationTemplatePath !== null) {
return $this->configurationTemplatePath;
}

return $this->innerService->getConfigurationTemplatePath();
return $this->configurationTemplatePath;
}

public function setConfigurationNamespace(?string $configurationNamespace): self
Expand Down

0 comments on commit d8615e0

Please sign in to comment.