From e720f33843ced10c5abd6a4666eb9f83bd0a6135 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sat, 18 Jun 2016 10:01:25 +0200 Subject: [PATCH] Remove Kernel::setPuliFactoryClass() that existed only for testing --- src/Kernel.php | 14 +++----------- tests/KernelTest.php | 7 +++---- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Kernel.php b/src/Kernel.php index c48b75b..b3afa44 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -22,7 +22,7 @@ class Kernel * * @var string|null */ - private $puliFactoryClass; + public static $puliFactoryClass; /** * @var string[] @@ -52,12 +52,12 @@ public function __construct(array $modules = [], $environment = 'prod') */ public function createContainer() { - if (!$this->puliFactoryClass && !defined('PULI_FACTORY_CLASS')) { + if (!self::$puliFactoryClass && !defined('PULI_FACTORY_CLASS')) { throw new \RuntimeException('Puli is not installed'); } // Create Puli objects - $factoryClass = $this->puliFactoryClass ?: PULI_FACTORY_CLASS; + $factoryClass = self::$puliFactoryClass ?: PULI_FACTORY_CLASS; $factory = new $factoryClass(); /** @var ResourceRepository $repository */ $repository = $factory->createRepository(); @@ -86,14 +86,6 @@ public function createContainer() return $containerBuilder->build(); } - /** - * @param string $class - */ - public function setPuliFactoryClass($class) - { - $this->puliFactoryClass = $class; - } - /** * Override this method to configure the cache to use for container definitions. * diff --git a/tests/KernelTest.php b/tests/KernelTest.php index 672157c..fae25f4 100644 --- a/tests/KernelTest.php +++ b/tests/KernelTest.php @@ -22,9 +22,10 @@ public function setUp() PuliFactoryClass::$repository = new InMemoryRepository(); PuliFactoryClass::$discovery = new InMemoryDiscovery(); - $this->kernel = new Kernel(); // Mock the Puli factory - $this->kernel->setPuliFactoryClass(PuliFactoryClass::class); + Kernel::$puliFactoryClass = PuliFactoryClass::class; + + $this->kernel = new Kernel(); } /** @@ -63,7 +64,6 @@ public function loads_module_configs() $this->kernel = new Kernel([ 'blog', ]); - $this->kernel->setPuliFactoryClass(PuliFactoryClass::class); $container = $this->kernel->createContainer(); $this->assertEquals('bar', $container->get('foo')); @@ -80,7 +80,6 @@ public function loads_module_environment_config() $this->kernel = new Kernel([ 'blog', ], 'dev'); - $this->kernel->setPuliFactoryClass(PuliFactoryClass::class); $container = $this->kernel->createContainer(); $this->assertEquals('biz', $container->get('foo'));