Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,15 +458,16 @@ public function getFinalHandler(ResponseInterface $response = null)
/**
* Retrieve an emitter to use during run().
*
* If none was registered during instantiation, this will lazy-load a
* SapiEmitter instance.
* If none was registered during instantiation, this will lazy-load an
* EmitterStack composing an SapiEmitter instance.
*
* @return EmitterInterface
*/
public function getEmitter()
{
if (! $this->emitter) {
$this->emitter = new SapiEmitter;
$this->emitter = new Emitter\EmitterStack();
$this->emitter->push(new SapiEmitter());
}
return $this->emitter;
}
Expand Down
14 changes: 1 addition & 13 deletions src/Container/ApplicationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function __invoke(ContainerInterface $container)

$emitter = $container->has(EmitterInterface::class)
? $container->get(EmitterInterface::class)
: $this->createEmitterStack();
: null;

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

Expand Down Expand Up @@ -175,18 +175,6 @@ private function injectRoutes(Application $app, ContainerInterface $container)
}
}

/**
* Create the default emitter stack.
*
* @return EmitterStack
*/
private function createEmitterStack()
{
$emitter = new EmitterStack();
$emitter->push(new SapiEmitter());
return $emitter;
}

/**
* Given a collection of middleware specifications, pipe them to the application.
*
Expand Down
14 changes: 10 additions & 4 deletions test/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
use PHPUnit_Framework_TestCase as TestCase;
use Prophecy\Argument;
use ReflectionProperty;
use Zend\Diactoros\Response\SapiEmitter;
use Zend\Diactoros\ServerRequest as Request;
use Zend\Expressive\Application;
use Zend\Expressive\Emitter\EmitterStack;
use Zend\Expressive\Router\Route;
use Zend\Expressive\Router\RouteResult;
use Zend\Stratigility\Route as StratigilityRoute;
Expand Down Expand Up @@ -260,11 +262,15 @@ public function testFinalHandlerIsUsedAtInvocationIfNoOutArgumentIsSupplied()
$this->assertSame($finalResponse, $test);
}

public function testComposesSapiEmitterByDefault()
public function testComposesEmitterStackWithSapiEmitterByDefault()
{
$app = $this->getApp();
$emitter = $app->getEmitter();
$this->assertInstanceOf('Zend\Diactoros\Response\SapiEmitter', $emitter);
$app = $this->getApp();
$stack = $app->getEmitter();
$this->assertInstanceOf(EmitterStack::class, $stack);

$this->assertCount(1, $stack);
$test = $stack->pop();
$this->assertInstanceOf(SapiEmitter::class, $test);
}

public function testAllowsInjectingEmitterAtInstantiation()
Expand Down