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

Commit

Permalink
Merge branch 'develop' of git://github.com/zendframework/zf2 into dev…
Browse files Browse the repository at this point in the history
…elop
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/Feature/FormElementProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ModuleManager
*/

namespace Zend\ModuleManager\Feature;

/**
* @category Zend
* @package Zend_ModuleManager
* @subpackage Feature
*/
interface FormElementProviderInterface
{
/**
* Expected to return \Zend\ServiceManager\Config object or array to
* seed such an object.
*
* @return array|\Zend\ServiceManager\Config
*/
public function getFormElementConfig();
}
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 1a640d1

Please sign in to comment.