Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OXDEV-1284 Introduce test container factory
- Loading branch information
1 parent
d71bb1f
commit bbf2f19
Showing
4 changed files
with
63 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\EshopCommunity\Tests\Integration\Internal; | ||
|
||
use OxidEsales\EshopCommunity\Internal\Application\ContainerBuilder; | ||
use OxidEsales\Facts\Facts; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder as SymfonyContainerBuilder; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class TestContainerFactory | ||
{ | ||
public function create(): SymfonyContainerBuilder | ||
{ | ||
$containerBuilder = new ContainerBuilder(new Facts()); | ||
$container = $containerBuilder->getContainer(); | ||
|
||
$container = $this->setAllServicesAsPublic($container); | ||
$container = $this->setTestProjectConfigurationFile($container); | ||
|
||
return $container; | ||
} | ||
|
||
private function setAllServicesAsPublic(SymfonyContainerBuilder $container): SymfonyContainerBuilder | ||
{ | ||
foreach ($container->getDefinitions() as $definition) { | ||
$definition->setPublic(true); | ||
} | ||
|
||
return $container; | ||
} | ||
|
||
private function setTestProjectConfigurationFile(SymfonyContainerBuilder $container): SymfonyContainerBuilder | ||
{ | ||
$projectConfigurationYmlStorageDefinition = $container->getDefinition('oxid_esales.module.configuration.project_configuration_yaml_file_storage'); | ||
$projectConfigurationYmlStorageDefinition->setArgument( | ||
'$filePath', | ||
tempnam(sys_get_temp_dir() . '/test_project_configuration', 'test_') | ||
); | ||
$container->setDefinition( | ||
'oxid_esales.module.configuration.project_configuration_yaml_file_storage', | ||
$projectConfigurationYmlStorageDefinition | ||
); | ||
|
||
return $container; | ||
} | ||
} |