Introduce Container Configurator

Container factory is now responsible only for building or loading cached container. Container configuration is done within the ContainerConfigurator
[PREMIUM-99]
This commit is contained in:
Rostislav Wolny
2018-12-04 14:42:44 +01:00
parent b5bc4b2609
commit 884cabb51f
5 changed files with 102 additions and 66 deletions

View File

@ -12,6 +12,7 @@ use MailPoet\API\JSON\SuccessResponse;
use MailPoet\API\JSON\v1\APITestNamespacedEndpointStubV1;
use MailPoet\API\JSON\v2\APITestNamespacedEndpointStubV2;
use MailPoet\Config\AccessControl;
use MailPoet\DI\ContainerConfigurator;
use MailPoetVendor\Symfony\Component\DependencyInjection\Container;
use MailPoet\DI\ContainerFactory;
use MailPoet\WP\Hooks;
@ -35,12 +36,12 @@ class APITest extends \MailPoetTest {
} else {
$this->wp_user_id = $wp_user_id;
}
$container_factory = new ContainerFactory();
$this->container = $container_factory->createContainer();
$container_factory = new ContainerFactory(new ContainerConfigurator());
$this->container = $container_factory->getConfiguredContainer();
$this->container->autowire(APITestNamespacedEndpointStubV1::class)->setPublic(true);
$this->container->autowire(APITestNamespacedEndpointStubV2::class)->setPublic(true);
$this->container->compile();
$this->api = $this->container->get(\MailPoet\API\JSON\API::class);
$this->api = new \MailPoet\API\JSON\API($this->container, $this->container->get(AccessControl::class));
}
function testItCallsAPISetupAction() {