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

Commit

Permalink
Merge branch 'weierophinney-hotfix/2821-loadmodule' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ModuleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public function loadModule($moduleName)
}
$event->setModule($module);

$this->getEventManager()->trigger(ModuleEvent::EVENT_LOAD_MODULE, $this, $event);
$this->loadedModules[$moduleName] = $module;
$this->getEventManager()->trigger(ModuleEvent::EVENT_LOAD_MODULE, $this, $event);

$this->loadFinished = true;

Expand Down
19 changes: 19 additions & 0 deletions test/ModuleManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
namespace ZendTest\ModuleManager;

use PHPUnit_Framework_TestCase as TestCase;
use stdClass;
use Zend\EventManager\EventManager;
use Zend\Loader\AutoloaderFactory;
use Zend\ModuleManager\Listener\ListenerOptions;
use Zend\ModuleManager\Listener\DefaultListenerAggregate;
use Zend\ModuleManager\ModuleEvent;
use Zend\ModuleManager\ModuleManager;
use InvalidArgumentException;

Expand Down Expand Up @@ -142,4 +144,21 @@ public function testCanLoadModuleDuringTheLoadModuleEvent()
$this->assertTrue(isset($config['loaded']));
$this->assertSame('oh, yeah baby!', $config['loaded']);
}

public function testModuleIsMarkedAsLoadedWhenLoadModuleEventIsTriggered()
{
$test = new stdClass;
$moduleManager = new ModuleManager(array('BarModule'));
$events = $moduleManager->getEventManager();
$events->attachAggregate($this->defaultListeners);
$events->attach(ModuleEvent::EVENT_LOAD_MODULE, function ($e) use ($test) {
$test->modules = $e->getTarget()->getLoadedModules(false);
});

$moduleManager->loadModules();

$this->assertTrue(isset($test->modules));
$this->assertArrayHasKey('BarModule', $test->modules);
$this->assertInstanceOf('BarModule\Module', $test->modules['BarModule']);
}
}

0 comments on commit b38977d

Please sign in to comment.