Skip to content
Permalink
Browse files

OXDEV-1287 Move VFS setup from context to TestContainerFactory

  • Loading branch information...
iegupov committed Jul 5, 2019
1 parent 1a747cf commit 508a09d0ab85c233f9d2d616d7a039e2dbe2e3d2
Showing with 41 additions and 14 deletions.
  1. +33 −3 tests/Integration/Internal/TestContainerFactory.php
  2. +8 −11 tests/Unit/Internal/BasicContextStub.php
@@ -6,7 +6,7 @@
namespace OxidEsales\EshopCommunity\Tests\Integration\Internal;
use OxidEsales\EshopCommunity\Internal\Application\BootstrapContainer\BootstrapContainerFactory;
use org\bovigo\vfs\vfsStream;
use OxidEsales\EshopCommunity\Internal\Application\ContainerBuilder;
use OxidEsales\EshopCommunity\Internal\Application\Utility\BasicContextInterface;
use OxidEsales\EshopCommunity\Tests\Unit\Internal\BasicContextStub;
@@ -17,9 +17,20 @@
*/
class TestContainerFactory
{
/**
* @var BasicContextStub
*/
private $context;
public function __construct()
{
$this->prepareVFS();
$this->context = $this->getBasicContextStub();
}
public function create(): SymfonyContainerBuilder
{
$containerBuilder = new ContainerBuilder(new BasicContextStub());
$containerBuilder = new ContainerBuilder($this->context);
$container = $containerBuilder->getContainer();
$container = $this->setAllServicesAsPublic($container);
@@ -39,9 +50,28 @@ private function setAllServicesAsPublic(SymfonyContainerBuilder $container): Sym
private function setBasicContextStub(SymfonyContainerBuilder $container): SymfonyContainerBuilder
{
$container->set(BasicContextInterface::class, new BasicContextStub());
$container->set(BasicContextInterface::class, $this->context);
$container->autowire(BasicContextInterface::class, BasicContextStub::class);
return $container;
}
private function getBasicContextStub(): BasicContextStub
{
$context = new BasicContextStub();
$context->setProjectConfigurationDirectory($this->getTestProjectConfigurationDirectory());
return $context;
}
private function prepareVFS(): void
{
$vfsStreamDirectory = vfsStream::setup('project_configuration');
vfsStream::create([], $vfsStreamDirectory);
}
private function getTestProjectConfigurationDirectory(): string
{
return vfsStream::url('project_configuration/');
}
}
@@ -7,7 +7,6 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal;
use org\bovigo\vfs\vfsStream;
use OxidEsales\EshopCommunity\Internal\Application\BootstrapContainer\BootstrapContainerFactory;
use OxidEsales\EshopCommunity\Internal\Application\Utility\BasicContextInterface;
@@ -46,8 +45,6 @@ public function __construct()
$this->shopRootPath = $basicContext->getShopRootPath();
$this->environment = $basicContext->getEnvironment();
$this->backwardsCompatibilityClassMap = $basicContext->getBackwardsCompatibilityClassMap();
$this->prepareVFS();
}
/**
@@ -210,6 +207,14 @@ public function getProjectConfigurationDirectory(): string
return $this->projectConfigurationDirectory;
}
/**
* @param string $projectConfigurationDirectory
*/
public function setProjectConfigurationDirectory(string $projectConfigurationDirectory): void
{
$this->projectConfigurationDirectory = $projectConfigurationDirectory;
}
/**
* @return string
*/
@@ -241,12 +246,4 @@ public function getShopRootPath(): string
{
return $this->shopRootPath;
}
private function prepareVFS()
{
$vfsStreamDirectory = vfsStream::setup('project_configuration');
vfsStream::create([], $vfsStreamDirectory);
$this->projectConfigurationDirectory = vfsStream::url('project_configuration/');
}
}

0 comments on commit 508a09d

Please sign in to comment.
You can’t perform that action at this time.