-
-
Notifications
You must be signed in to change notification settings - Fork 443
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[4.x] Improve RootUrl and UrlGenerator bootstrappers #1294
Merged
Merged
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
…rideInTests), work with resolved UrlGenerator
…of creating it on every app('url') call
…ion test for using UrlGenerator and RootUrl bootstrappers together
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1294 +/- ##
============================================
- Coverage 85.00% 84.66% -0.34%
- Complexity 1027 1053 +26
============================================
Files 174 176 +2
Lines 3020 3084 +64
============================================
+ Hits 2567 2611 +44
- Misses 453 473 +20 ☔ View full report in Codecov by Sentry. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR description copied from https://github.com/tenancy-for-laravel/v4/pull/60
RootUrlBootstrapper
The bootstrapper now only has an effect in CLI by default. To make the bootstrapper have an effect in the tests (e.g. for testing if it works correctly),
RootUrlBootstrapper::$rootUrlOverrideInTests
has to be set totrue
.Apart from the fact that the bootstrapper should only have an effect in CLI, I added this because I noticed that
Livewire::test()
is broken when using this bootstrapper with path identification – duringLivewire::test()
, LW creates a route (livewire-unit-test-endpoint) that can't be accessed when using the root URL override with path identification. It can't be accessed because when the root URL is overridden like "app.test/tenantfoo", the app tries to reach "tenantfoo/livewire-unit-test-endpoint", which is a route that doesn't exist, and I haven't found any way of dealing with that.RootUrlBootstrapper (UrlGenerator override)
Resolving
app('url')
was always creating new instances of TenancyUrlGenerator because the instance creation was handled in the closure passed toapp()->extend()
. This is now solved by creating the instance before binding it to'url'
.TenancyUrlGenerator also wasn't properly reverted to the original UrlGenerator while ending tenancy – solved this by using
app()->extend()
in the bootstrapper'srevert()
instead ofapp()->bind()
.Combining RootUrlBootstrapper with UrlGeneratorBootstrapper (section updated)
RootUrlBootstrapper cannot be combined with UrlGeneratorBootstrapper because allowing that introduces too much unnecessary complexity, and there aren't really use cases for combining these bootstrappers. So we should recommend only using one, or the other, based on the identification method (RootUrlBootstrapper -- multi-domain, UrlGeneratorBootstrapper -- path).