Permalink
Browse files

Merge branch 'feature/bootstrapping-an-app-work' into develop

  • Loading branch information...
2 parents 588f4bd + 1bec82d commit 3591de181c46ae73122d01b8e0d027dd3a072b46 @trq trq committed Feb 7, 2013
Showing with 23 additions and 24 deletions.
  1. +2 −2 lib/Proem/Bootstrap/Dispatch.php
  2. +1 −1 lib/Proem/Bootstrap/Request.php
  3. +1 −1 lib/Proem/Bootstrap/Route.php
  4. +7 −6 lib/Proem/Proem.php
  5. +12 −14 tests/ProemTest.php
@@ -59,7 +59,7 @@ public function in(AssetManagerInterface $assetManager)
new Event('proem.in.setup.dispatch'),
function ($responseEvent) use ($assetManager) {
// Check for a customized Dispatch\Dispatcher.
- if ($responseEvent->has('dispatcherAsset')) {
+ if ($responseEvent instanceof Event && $responseEvent->has('dispatcherAsset')) {
$assetManager->overrideAsSingleton('dispatcher', $responseEvent->get('dispatcherAsset'));
}
}
@@ -70,7 +70,7 @@ function ($responseEvent) use ($assetManager) {
new Event('proem.in.dispatch'),
function ($responseEvent) use ($assetManager) {
// Check for a customised dispatch handler.
- if ($responseEvent->has('dispatchHandler') && $responseEvent->get('dispatcherHandler') instanceof \Closure) {
+ if ($responseEvent instanceof Event && $responseEvent->has('dispatchHandler') && $responseEvent->get('dispatcherHandler') instanceof \Closure) {
$action = $responseEvent->get('dispatcherHandler');
$action($assetManager->resolve('request'));
} else {
@@ -60,7 +60,7 @@ public function in(AssetManagerInterface $assetManager)
$assetManager->resolve('eventManager')->trigger(
new Event('proem.in.setup.request'),
function ($responseEvent) use ($assetManager) {
- if ($responseEvent->has('requestAsset')) {
+ if ($responseEvent instanceof Event && $responseEvent->has('requestAsset')) {
$assetManager->override('request', $responseEvent->get('requestAsset'));
}
}
@@ -65,7 +65,7 @@ public function in(AssetManagerInterface $assetManager)
$assetManager->resolve('eventManager')->trigger(
new Event('proem.in.setup.route'),
function ($responseEvent) use ($assetManager) {
- if ($responseEvent->has('routeManagerAsset')) {
+ if ($responseEvent instanceof Event && $responseEvent->has('routeManagerAsset')) {
$assetManager->override('routeManager', $responseEvent->get('routeManagerAsset'));
}
}
View
@@ -65,12 +65,13 @@ public function __construct(AssetManagerInterface $assetManager = null)
$this->assetManager = $assetManager;
}
- $this->assetManager->alias([
- 'Proem\Signal\EventManagerInterface' => 'Proem\Signal\EventManager',
- 'eventManager' => 'Proem\Signal\EventManagerInterface',
- 'Proem\Filter\ChainManagerInterface' => 'Proem\Filter\ChainManager',
- 'chainManager' => 'Proem\Filter\ChainManagerInterface'
- ]);
+ $this->assetManager->singleton(['eventManager' => '\Proem\Signal\EventManager']);
+ $this->assetManager->singleton(['chainManager' => '\Proem\Filter\ChainManager']);
+ }
+
+ public function getEventManager()
+ {
+ return $this->assetManager->resolve('eventManager');
}
/**
View
@@ -35,14 +35,13 @@ public function testCanInstantiateProem()
{
$assetManager = m::mock('\Proem\Service\AssetManagerInterface');
$assetManager
- ->shouldReceive('alias')
+ ->shouldReceive('singleton')
->once()
- ->with([
- 'Proem\Signal\EventManagerInterface' => 'Proem\Signal\EventManager',
- 'eventManager' => 'Proem\Signal\EventManagerInterface',
- 'Proem\Filter\ChainManagerInterface' => 'Proem\Filter\ChainManager',
- 'chainManager' => 'Proem\Filter\ChainManagerInterface'
- ]);
+ ->with(['eventManager' => '\Proem\Signal\EventManager'])
+
+ ->shouldReceive('singleton')
+ ->once()
+ ->with(['chainManager' => '\Proem\Filter\ChainManager']);
$this->assertInstanceOf('Proem\Proem', new Proem($assetManager));
}
@@ -70,14 +69,13 @@ public function testLoadsDefaultEventManager()
$assetManager = m::mock('\Proem\Service\AssetManagerInterface');
$assetManager
- ->shouldReceive('alias')
+ ->shouldReceive('singleton')
+ ->once()
+ ->with(['eventManager' => '\Proem\Signal\EventManager'])
+
+ ->shouldReceive('singleton')
->once()
- ->with([
- 'Proem\Signal\EventManagerInterface' => 'Proem\Signal\EventManager',
- 'eventManager' => 'Proem\Signal\EventManagerInterface',
- 'Proem\Filter\ChainManagerInterface' => 'Proem\Filter\ChainManager',
- 'chainManager' => 'Proem\Filter\ChainManagerInterface'
- ])
+ ->with(['chainManager' => '\Proem\Filter\ChainManager'])
->shouldReceive('resolve')
->once()

0 comments on commit 3591de1

Please sign in to comment.