This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +22
-20
lines changed Expand file tree Collapse file tree 5 files changed +22
-20
lines changed Original file line number Diff line number Diff line change 66 <testsuites >
77 <testsuite name =" zend-expressive-response-factory" >
88 <file >./test/Container/ResponseFactoryWithoutDiactorosTest.php</file >
9- <file >./test/Container/StreamFactoryWithoutDiactorosTest .php</file >
9+ <file >./test/Container/StreamFactoryFactoryWithoutDiactorosTest .php</file >
1010 </testsuite >
1111 <testsuite name =" zend-expressive" >
1212 <directory >./test</directory >
1313 <exclude >./test/Container/ResponseFactoryWithoutDiactorosTest.php</exclude >
14- <exclude >./test/Container/StreamFactoryWithoutDiactorosTest .php</exclude >
14+ <exclude >./test/Container/StreamFactoryFactoryWithoutDiactorosTest .php</exclude >
1515 </testsuite >
1616 </testsuites >
1717
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ public function getDependencies() : array
5050 NOT_FOUND_RESPONSE => Container \ResponseFactory::class,
5151 RequestHandlerRunner::class => Container \RequestHandlerRunnerFactory::class,
5252 Router \IMPLICIT_HEAD_MIDDLEWARE_RESPONSE => Container \ResponseFactory::class,
53- Router \IMPLICIT_HEAD_MIDDLEWARE_STREAM_FACTORY => Container \StreamFactory ::class,
53+ Router \IMPLICIT_HEAD_MIDDLEWARE_STREAM_FACTORY => Container \StreamFactoryFactory ::class,
5454 Router \IMPLICIT_OPTIONS_MIDDLEWARE_RESPONSE => Container \ResponseFactory::class,
5555 Router \METHOD_NOT_ALLOWED_MIDDLEWARE_RESPONSE => Container \ResponseFactory::class,
5656 SERVER_REQUEST_ERROR_RESPONSE_GENERATOR => Container \ServerRequestErrorResponseGeneratorFactory::class,
Original file line number Diff line number Diff line change 1010namespace Zend \Expressive \Container ;
1111
1212use Psr \Container \ContainerInterface ;
13- use Psr \Http \Message \StreamInterface ;
1413use Zend \Diactoros \Stream ;
1514
1615/**
17- * Produces an empty stream for use with services that need to produce a stream
18- * for use with a request or a response. This service should be non-shared, if
19- * your container supports that possibility, to ensure that the stream it
20- * composes cannot be written to by any other consumer.
16+ * Produces a callable capable of producing an empty stream for use with
17+ * services that need to produce a stream for use with a request or a response.
2118 */
22- class StreamFactory
19+ class StreamFactoryFactory
2320{
24- public function __invoke (ContainerInterface $ container ) : StreamInterface
21+ public function __invoke (ContainerInterface $ container ) : callable
2522 {
2623 if (! class_exists (Stream::class)) {
2724 throw new Exception \InvalidServiceException (sprintf (
@@ -35,6 +32,8 @@ public function __invoke(ContainerInterface $container) : StreamInterface
3532 ));
3633 }
3734
38- return new Stream ('php://temp ' , 'wb+ ' );
35+ return function () : Stream {
36+ return new Stream ('php://temp ' , 'wb+ ' );
37+ };
3938 }
4039}
Original file line number Diff line number Diff line change 1212use PHPUnit \Framework \TestCase ;
1313use Psr \Container \ContainerInterface ;
1414use Zend \Diactoros \Stream ;
15- use Zend \Expressive \Container \StreamFactory ;
15+ use Zend \Expressive \Container \StreamFactoryFactory ;
1616
17- class StreamFactoryTest extends TestCase
17+ class StreamFactoryFactoryTest extends TestCase
1818{
19- public function testFactoryProducesAStreamWhenDiactorosIsInstalled ()
19+ public function testFactoryProducesACallableCapableOfGeneratingAStreamWhenDiactorosIsInstalled ()
2020 {
2121 $ container = $ this ->prophesize (ContainerInterface::class)->reveal ();
22- $ factory = new StreamFactory ();
22+ $ factory = new StreamFactoryFactory ();
2323
24- $ response = $ factory ($ container );
24+ $ result = $ factory ($ container );
2525
26- $ this ->assertInstanceOf (Stream::class, $ response );
26+ $ this ->assertInternalType ('callable ' , $ result );
27+
28+ $ stream = $ result ();
29+ $ this ->assertInstanceOf (Stream::class, $ stream );
2730 }
2831}
Original file line number Diff line number Diff line change 1313use Psr \Container \ContainerInterface ;
1414use Throwable ;
1515use Zend \Expressive \Container \Exception \InvalidServiceException ;
16- use Zend \Expressive \Container \StreamFactory ;
16+ use Zend \Expressive \Container \StreamFactoryFactory ;
1717
18- class StreamFactoryWithoutDiactorosTest extends TestCase
18+ class StreamFactoryFactoryWithoutDiactorosTest extends TestCase
1919{
2020 private $ autoloadFunctions = [];
2121
@@ -24,7 +24,7 @@ public function setUp()
2424 class_exists (InvalidServiceException::class);
2525
2626 $ this ->container = $ this ->prophesize (ContainerInterface::class)->reveal ();
27- $ this ->factory = new StreamFactory ();
27+ $ this ->factory = new StreamFactoryFactory ();
2828
2929 foreach (spl_autoload_functions () as $ autoloader ) {
3030 if (! is_array ($ autoloader )) {
You can’t perform that action at this time.
0 commit comments