diff --git a/.travis.yml b/.travis.yml index 02802796..c5e10341 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,6 @@ install: - if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi - if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi - if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi - - if [[ $TEST_COVERAGE == 'true' ]]; then cp phpunit.xml.dist-coverage phpunit.xml.dist ; fi - stty cols 120 && composer show - cat phpunit.xml.dist diff --git a/CHANGELOG.md b/CHANGELOG.md index 87b7001c..4e5d8867 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,34 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## 3.0.0rc4 - 2018-03-13 + +### Added + +- Nothing. + +### Changed + +- Forward ports a change made in [#581](https://github.com/zendframework/zend-expressive/pull/581) + to how the `ApplicationConfigInjectionDelegator::injectPipelineFromConfig()` + method works. Previously, it would auto-inject routing and dispatch middleware + if routes were configured, but no `middleware_pipeline` was present. + Considering that this method will always be called manually, this + functionality was removed; the method now becomes a no-op if no + `middleware_pipeline` is present. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- Nothing. + ## 3.0.0rc3 - 2018-03-07 ### Added diff --git a/phpcs.xml b/phpcs.xml index 2bebf4c4..25521bf1 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -5,8 +5,4 @@ src test - - - src/AppFactory.php - diff --git a/phpunit.xml.dist-coverage b/phpunit.xml.dist-coverage deleted file mode 100644 index e321765d..00000000 --- a/phpunit.xml.dist-coverage +++ /dev/null @@ -1,18 +0,0 @@ - - - - - ./test - - - - - - src - - - diff --git a/src/Container/ApplicationConfigInjectionDelegator.php b/src/Container/ApplicationConfigInjectionDelegator.php index ec30e06c..1d1aa893 100644 --- a/src/Container/ApplicationConfigInjectionDelegator.php +++ b/src/Container/ApplicationConfigInjectionDelegator.php @@ -61,9 +61,6 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal * Inspects the configuration provided to determine if a middleware pipeline * exists to inject in the application. * - * If no pipeline is defined, but routes *are*, then the method will inject - * the routing and dispatch middleware. - * * Use the following configuration format: * * @@ -129,7 +126,38 @@ public static function injectPipelineFromConfig(Application $application, array /** * Inject routes from configuration. * - * Proxies to ApplicationConfigInjectionDelegator::injectRoutesFromConfig + * Introspects the provided configuration for routes to inject in the + * application instance. + * + * The following configuration structure can be used to define routes: + * + * + * return [ + * 'routes' => [ + * [ + * 'path' => '/path/to/match', + * 'middleware' => 'Middleware Service Name or Callable', + * 'allowed_methods' => ['GET', 'POST', 'PATCH'], + * 'options' => [ + * 'stuff' => 'to', + * 'pass' => 'to', + * 'the' => 'underlying router', + * ], + * ], + * // etc. + * ], + * ]; + * + * + * Each route MUST have a path and middleware key at the minimum. + * + * The "allowed_methods" key may be omitted, can be either an array or the + * value of the Zend\Expressive\Router\Route::HTTP_METHOD_ANY constant; any + * valid HTTP method token is allowed, which means you can specify custom HTTP + * methods as well. + * + * The "options" key may also be omitted, and its interpretation will be + * dependent on the underlying router used. * * @throws InvalidArgumentException */ @@ -144,7 +172,7 @@ public static function injectRoutesFromConfig(Application $application, array $c continue; } - $methods = null; + $methods = Route::HTTP_METHOD_ANY; if (isset($spec['allowed_methods'])) { $methods = $spec['allowed_methods']; if (! is_array($methods)) { diff --git a/test/ConfigProviderTest.php b/test/ConfigProviderTest.php index 861b1f2c..3824c2b1 100644 --- a/test/ConfigProviderTest.php +++ b/test/ConfigProviderTest.php @@ -63,10 +63,17 @@ public function testProviderDefinesExpectedFactoryServices() $factories = $config['factories']; $this->assertArrayHasKey(Application::class, $factories); + $this->assertArrayHasKey(ApplicationPipeline::class, $factories); + $this->assertArrayHasKey(EmitterInterface::class, $factories); $this->assertArrayHasKey(ErrorHandler::class, $factories); + $this->assertArrayHasKey(MiddlewareContainer::class, $factories); + $this->assertArrayHasKey(MiddlewareFactory::class, $factories); $this->assertArrayHasKey(Middleware\ErrorResponseGenerator::class, $factories); $this->assertArrayHasKey(NotFoundHandler::class, $factories); + $this->assertArrayHasKey(RequestHandlerRunner::class, $factories); $this->assertArrayHasKey(ResponseInterface::class, $factories); + $this->assertArrayHasKey(ServerRequestInterface::class, $factories); + $this->assertArrayHasKey(ServerRequestErrorResponseGenerator::class, $factories); $this->assertArrayHasKey(StreamInterface::class, $factories); } diff --git a/test/Container/ApplicationConfigInjectionDelegatorTest.php b/test/Container/ApplicationConfigInjectionDelegatorTest.php index 7e398062..35da925c 100644 --- a/test/Container/ApplicationConfigInjectionDelegatorTest.php +++ b/test/Container/ApplicationConfigInjectionDelegatorTest.php @@ -31,7 +31,6 @@ use Zend\HttpHandlerRunner\RequestHandlerRunner; use Zend\Stratigility\MiddlewarePipe; use ZendTest\Expressive\ContainerTrait; -use ZendTest\Expressive\TestAsset\CallableInteropMiddleware; use ZendTest\Expressive\TestAsset\InvokableMiddleware; class ApplicationConfigInjectionDelegatorTest extends TestCase @@ -200,12 +199,12 @@ public static function assertMethodNotAllowedMiddleware(MiddlewareInterface $mid public function callableMiddlewares() { return [ - [CallableInteropMiddleware::class], + ['HelloWorld'], [ - function ($request, DelegateInterface $delegate) { + function () { }, ], - [[CallableInteropMiddleware::class, 'staticallyCallableMiddleware']], + [[InvokableMiddleware::class, 'staticallyCallableMiddleware']], ]; } diff --git a/test/Router/IntegrationTest.php b/test/Router/IntegrationTest.php index 21439e9b..acd4748b 100644 --- a/test/Router/IntegrationTest.php +++ b/test/Router/IntegrationTest.php @@ -59,31 +59,6 @@ public function setUp() }; $this->router = $this->prophesize(RouterInterface::class); $this->container = $this->mockContainerInterface(); - $this->disregardDeprecationNotices(); - } - - public function tearDown() - { - restore_error_handler(); - } - - public function disregardDeprecationNotices() - { - set_error_handler(function ($errno, $errstr) { - if (strstr($errstr, 'pipe() the middleware directly')) { - return true; - } - if (strstr($errstr, 'doublePassMiddleware()')) { - return true; - } - if (strstr($errstr, 'ImplicitHeadMiddleware is deprecated')) { - return true; - } - if (strstr($errstr, 'ImplicitOptionsMiddleware is deprecated')) { - return true; - } - return false; - }, E_USER_DEPRECATED); } public function getApplication() diff --git a/test/TestAsset/CallableInteropMiddleware.php b/test/TestAsset/CallableInteropMiddleware.php index cf620678..1ab8bd2c 100644 --- a/test/TestAsset/CallableInteropMiddleware.php +++ b/test/TestAsset/CallableInteropMiddleware.php @@ -20,10 +20,4 @@ public function __invoke(ServerRequestInterface $request, RequestHandlerInterfac return $response->withHeader('X-Callable-Interop-Middleware', __CLASS__); } - - public static function staticallyCallableMiddleware(ServerRequestInterface $request, DelegateInterface $delegate) - { - $response = $delegate->process($request); - return $response->withHeader('X-Invoked', __CLASS__); - } }