Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Ensure HelperPluginManager constructor is forwards compatible #44

Merged
merged 1 commit into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/HelperPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,16 @@ class HelperPluginManager extends AbstractPluginManager
* Adds initializers to inject the attached renderer and translator, if
* any, to the currently requested helper.
*
* @param ContainerInterface $container
* @param array $config
* @param null|ConfigInterface|ContainerInterface $configOrContainerInstance
* @param array $v3config If $configOrContainerInstance is a container, this
* value will be passed to the parent constructor.
*/
public function __construct(ContainerInterface $container, array $config = [])
public function __construct($configOrContainerInstance = null, array $v3config = [])
{
$this->initializers[] = [$this, 'injectRenderer'];
$this->initializers[] = [$this, 'injectTranslator'];

parent::__construct($container, $config);
parent::__construct($configOrContainerInstance, $v3config);
}

/**
Expand Down
26 changes: 26 additions & 0 deletions test/HelperPluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,32 @@ public function setUp()
$this->helpers = new HelperPluginManager(new ServiceManager());
}

/**
* @group 43
*/
public function testConstructorArgumentsAreOptionalUnderV2()
{
if (method_exists($this->helpers, 'configure')) {
$this->markTestSkipped('zend-servicemanager v3 plugin managers require a container argument');
}

$helpers = new HelperPluginManager();
$this->assertInstanceOf(HelperPluginManager::class, $helpers);
}

/**
* @group 43
*/
public function testConstructorAllowsConfigInstanceAsFirstArgumentUnderV2()
{
if (method_exists($this->helpers, 'configure')) {
$this->markTestSkipped('zend-servicemanager v3 plugin managers require a container argument');
}

$helpers = new HelperPluginManager(new Config([]));
$this->assertInstanceOf(HelperPluginManager::class, $helpers);
}

public function testViewIsNullByDefault()
{
$this->assertNull($this->helpers->getRenderer());
Expand Down