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

Commit

Permalink
Merge branch 'tests/zendframework/zendframework#5948-circular-depende…
Browse files Browse the repository at this point in the history
…ncy-tests-for-module-manager-init'

Close zendframework/zendframework#5948
  • Loading branch information
Ocramius committed Apr 3, 2014
2 parents 15f1b17 + 1bbd0b4 commit 8a9ab31
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/ModuleManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,31 @@

class ModuleManagerTest extends TestCase
{
/**
* @var string
*/
protected $tmpdir;

/**
* @var string
*/
protected $configCache;

/**
* @var array
*/
protected $loaders;

/**
* @var string
*/
protected $includePath;

/**
* @var DefaultListenerAggregate
*/
protected $defaultListeners;

public function setUp()
{
$this->tmpdir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'zend_module_cache_dir';
Expand Down Expand Up @@ -161,6 +186,26 @@ public function testLoadingModuleFromAnotherModuleDemonstratesAppropriateSideEff
$this->assertSame('bar', $config['baz']);
}

/**
* @group 5651
* @group 5948
*/
public function testLoadingModuleFromAnotherModuleDoesNotInfiniteLoop()
{
$configListener = $this->defaultListeners->getConfigListener();
$moduleManager = new ModuleManager(array('LoadBarModule', 'LoadFooModule'));
$moduleManager->getEventManager()->attachAggregate($this->defaultListeners);
$moduleManager->loadModules();

$config = $configListener->getMergedConfig();

$this->assertTrue(isset($config['bar']));
$this->assertSame('bar', $config['bar']);

$this->assertTrue(isset($config['foo']));
$this->assertSame('bar', $config['foo']);
}

public function testModuleIsMarkedAsLoadedWhenLoadModuleEventIsTriggered()
{
$test = new stdClass;
Expand Down
28 changes: 28 additions & 0 deletions test/TestAsset/LoadBarModule/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace LoadBarModule;

use Zend\ModuleManager\ModuleManager;

class Module
{
public function init(ModuleManager $moduleManager)
{
$moduleManager->loadModule('LoadFooModule');
}

public function getConfig()
{
return array(
'bar' => 'bar',
'foo' => 'bar',
);
}
}
28 changes: 28 additions & 0 deletions test/TestAsset/LoadFooModule/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace LoadFooModule;

use Zend\ModuleManager\ModuleManager;

class Module
{
public function init(ModuleManager $moduleManager)
{
$moduleManager->loadModule('LoadBarModule');
}

public function getConfig()
{
return array(
'bar' => 'foo',
'foo' => 'foo',
);
}
}

0 comments on commit 8a9ab31

Please sign in to comment.