Skip to content

Commit

Permalink
Remove Kernel::setPuliFactoryClass() that existed only for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jun 18, 2016
1 parent 7582b4f commit e720f33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
14 changes: 3 additions & 11 deletions src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Kernel
*
* @var string|null
*/
private $puliFactoryClass;
public static $puliFactoryClass;

/**
* @var string[]
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
*
Expand Down
7 changes: 3 additions & 4 deletions tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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'));
Expand All @@ -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'));
Expand Down

0 comments on commit e720f33

Please sign in to comment.