This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
Ensure console (and controller!) usage works for v2 applications #81
Merged
weierophinney
merged 15 commits into
zendframework:develop
from
weierophinney:hotfix/console-usage
Feb 29, 2016
Merged
Ensure console (and controller!) usage works for v2 applications #81
weierophinney
merged 15 commits into
zendframework:develop
from
weierophinney:hotfix/console-usage
Feb 29, 2016
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v2 tests for `Console::isConsole()` to determine if the console router should be created; added code to the `RouterFactory::createService()` implementation to do that and overwrite the `$requestedName` when detected.
We originally removed the ServiceLocatorAwareInterface implementation from AbstractController when we were targeting a 3.0 release, but it needs to be present for a 2.7 release.
This functionality was removed when we were targeting a v3 release, but needs to be re-added when targeting v2.7.
- to allow retrieval with either `Console` or `console` as the service name.
Now that controllers re-implement ServiceLocatorAwareInterface, we get deprecation errors. By adding `PHPUnit_Framework_Error_Deprecated::$enabled = false` to the setup on these tests, we can eliminate having those cast to exceptions, and thus prevent them from marking tests as errored or failed.
Since zend-servicemanager v3 does not define `ServiceLocatorAwareInterface`, then we cannot extend it and still support that release series. As such, `AbstractController` no longer explicitly implements it, but does so implicitly by defining the methods. The initializers in both `ServiceManagerConfig` and `ControllerManager` were updated to *also* look for the combination: - interface `ServiceLocatorAwareInterface` does not exist AND - method `setServiceLocator()` is present If that combination is present, the same behavior is retained, including the deprecation notices.
After duck-typing the `ServiceLocatorAwareInterface` usage, two more tests showed failures due to deprecation notices; these have now been marked to exclude them.
Adds tests for both `ServiceManagerConfig` and `ControllerManager`, verifying that each can do duck-typed `ServiceLocatorAwareInterface` injection via the initializers they register.
The test cases removed are tested implicitly when retrieving aliases; however, they can never be retrieved directly, as they will not resolve to fully qualified class names. (When retrieving by alias, the FQCN is passed as the "requested name", which is why the factory works ever.)
Do not check if ServiceLocatorAwareInterface exists, as that will skip the initializer when it does, but the instance does not implement it and *does* fit duck typing rules.
weierophinney
added a commit
that referenced
this pull request
Feb 29, 2016
weierophinney
added a commit
that referenced
this pull request
Feb 29, 2016
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch is a result of testing the develop branch against Apigility. The only major show-stopper issue I ran across was with console usage, and this patch provides fixes as follows:
console
toConsoleAdapter
, to ensure retrieval can occur under that name.RouterFactory::createService()
method to test forConsole::isConsole()
and, if true, to set the$requestedName
passed to__invoke()
toConsoleRouter
. This ensures that the console router can be selected and used at runtime!ServiceLocatorAwareInterface
implementation inAbstractController
. It was removed originally when we were targeting a v3 release on the develop branch; now that we're targeting v2.7, it needs to be re-introduced.ServiceLocatorAwareInterface
initializer in theControllerManager
to ensure the application container is injected.At this point all testing has been integration testing; I'll add tests for this behavior shortly.