Skip to content

Commit e720f33

Browse files
committed
Remove Kernel::setPuliFactoryClass() that existed only for testing
1 parent 7582b4f commit e720f33

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/Kernel.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Kernel
2222
*
2323
* @var string|null
2424
*/
25-
private $puliFactoryClass;
25+
public static $puliFactoryClass;
2626

2727
/**
2828
* @var string[]
@@ -52,12 +52,12 @@ public function __construct(array $modules = [], $environment = 'prod')
5252
*/
5353
public function createContainer()
5454
{
55-
if (!$this->puliFactoryClass && !defined('PULI_FACTORY_CLASS')) {
55+
if (!self::$puliFactoryClass && !defined('PULI_FACTORY_CLASS')) {
5656
throw new \RuntimeException('Puli is not installed');
5757
}
5858

5959
// Create Puli objects
60-
$factoryClass = $this->puliFactoryClass ?: PULI_FACTORY_CLASS;
60+
$factoryClass = self::$puliFactoryClass ?: PULI_FACTORY_CLASS;
6161
$factory = new $factoryClass();
6262
/** @var ResourceRepository $repository */
6363
$repository = $factory->createRepository();
@@ -86,14 +86,6 @@ public function createContainer()
8686
return $containerBuilder->build();
8787
}
8888

89-
/**
90-
* @param string $class
91-
*/
92-
public function setPuliFactoryClass($class)
93-
{
94-
$this->puliFactoryClass = $class;
95-
}
96-
9789
/**
9890
* Override this method to configure the cache to use for container definitions.
9991
*

tests/KernelTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public function setUp()
2222
PuliFactoryClass::$repository = new InMemoryRepository();
2323
PuliFactoryClass::$discovery = new InMemoryDiscovery();
2424

25-
$this->kernel = new Kernel();
2625
// Mock the Puli factory
27-
$this->kernel->setPuliFactoryClass(PuliFactoryClass::class);
26+
Kernel::$puliFactoryClass = PuliFactoryClass::class;
27+
28+
$this->kernel = new Kernel();
2829
}
2930

3031
/**
@@ -63,7 +64,6 @@ public function loads_module_configs()
6364
$this->kernel = new Kernel([
6465
'blog',
6566
]);
66-
$this->kernel->setPuliFactoryClass(PuliFactoryClass::class);
6767
$container = $this->kernel->createContainer();
6868

6969
$this->assertEquals('bar', $container->get('foo'));
@@ -80,7 +80,6 @@ public function loads_module_environment_config()
8080
$this->kernel = new Kernel([
8181
'blog',
8282
], 'dev');
83-
$this->kernel->setPuliFactoryClass(PuliFactoryClass::class);
8483
$container = $this->kernel->createContainer();
8584

8685
$this->assertEquals('biz', $container->get('foo'));

0 commit comments

Comments
 (0)