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

Commit 64795b6

Browse files
committed
Merge branch 'hotfix/emitter-stack-by-default'
Close #102
2 parents 69eadac + a0de0bf commit 64795b6

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/Application.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,16 @@ public function getFinalHandler(ResponseInterface $response = null)
458458
/**
459459
* Retrieve an emitter to use during run().
460460
*
461-
* If none was registered during instantiation, this will lazy-load a
462-
* SapiEmitter instance.
461+
* If none was registered during instantiation, this will lazy-load an
462+
* EmitterStack composing an SapiEmitter instance.
463463
*
464464
* @return EmitterInterface
465465
*/
466466
public function getEmitter()
467467
{
468468
if (! $this->emitter) {
469-
$this->emitter = new SapiEmitter;
469+
$this->emitter = new Emitter\EmitterStack();
470+
$this->emitter->push(new SapiEmitter());
470471
}
471472
return $this->emitter;
472473
}

src/Container/ApplicationFactory.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function __invoke(ContainerInterface $container)
133133

134134
$emitter = $container->has(EmitterInterface::class)
135135
? $container->get(EmitterInterface::class)
136-
: $this->createEmitterStack();
136+
: null;
137137

138138
$app = new Application($router, $container, $finalHandler, $emitter);
139139

@@ -175,18 +175,6 @@ private function injectRoutes(Application $app, ContainerInterface $container)
175175
}
176176
}
177177

178-
/**
179-
* Create the default emitter stack.
180-
*
181-
* @return EmitterStack
182-
*/
183-
private function createEmitterStack()
184-
{
185-
$emitter = new EmitterStack();
186-
$emitter->push(new SapiEmitter());
187-
return $emitter;
188-
}
189-
190178
/**
191179
* Given a collection of middleware specifications, pipe them to the application.
192180
*

test/ApplicationTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
use PHPUnit_Framework_TestCase as TestCase;
1414
use Prophecy\Argument;
1515
use ReflectionProperty;
16+
use Zend\Diactoros\Response\SapiEmitter;
1617
use Zend\Diactoros\ServerRequest as Request;
1718
use Zend\Expressive\Application;
19+
use Zend\Expressive\Emitter\EmitterStack;
1820
use Zend\Expressive\Router\Route;
1921
use Zend\Expressive\Router\RouteResult;
2022
use Zend\Stratigility\Route as StratigilityRoute;
@@ -260,11 +262,15 @@ public function testFinalHandlerIsUsedAtInvocationIfNoOutArgumentIsSupplied()
260262
$this->assertSame($finalResponse, $test);
261263
}
262264

263-
public function testComposesSapiEmitterByDefault()
265+
public function testComposesEmitterStackWithSapiEmitterByDefault()
264266
{
265-
$app = $this->getApp();
266-
$emitter = $app->getEmitter();
267-
$this->assertInstanceOf('Zend\Diactoros\Response\SapiEmitter', $emitter);
267+
$app = $this->getApp();
268+
$stack = $app->getEmitter();
269+
$this->assertInstanceOf(EmitterStack::class, $stack);
270+
271+
$this->assertCount(1, $stack);
272+
$test = $stack->pop();
273+
$this->assertInstanceOf(SapiEmitter::class, $test);
268274
}
269275

270276
public function testAllowsInjectingEmitterAtInstantiation()

0 commit comments

Comments
 (0)