Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
- Any call to
url()
requires an installed, working, and correct database schema of {url_alias}.
Goal
- Provide a in-memory/mock implementation of Path\AliasManager to remove the dependency on {url_alias} when it is not needed.
Comment | File | Size | Author |
---|---|---|---|
#10 | drupal-1893730-9.patch | 20.88 KB | dawehner |
#7 | drupal-1893730-7.patch | 10.54 KB | dawehner |
#7 | interdiff.txt | 3.28 KB | dawehner |
#3 | drupal-1893730-3.patch | 9.29 KB | dawehner |
Comments
Comment #1
webchickThis sounds related to #1888424: Make Drupal's URL generation logic available to HttpKernel, and minimize code repetition/divergence.
Comment #2
dawehnerAssigning.
Comment #3
dawehnerThat's just a first step, let's see how many of the unit tests break with that.
Comment #4
BerdirI think this should just be registered when needed, like the other in memory implementations.
Comment #5
sunThis patch should allow us to remove all
from all DUTB tests; e.g., one of them is Drupal\filter\Tests\FilterDefaultConfigTest.
If possible, we should do that as part of this issue + patch.
Comment #6
Eric_A CreditAttribution: Eric_A commentedFYI: This test and others are postponed. HEAD seems to be broken. So far no issue seems to have been identified as the source of the problem.
Comment #7
dawehnerThanks for the review!
* Finger crossing *
Comment #8
sunHm. Technically, Path\AliasTest should be rewritten so that it can be re-used for both implementations. That is, because we expect both implementations to work identically. An example for that can be found in Config\Storage\ tests (DUTB), but also in Cache backend tests (unit). In essence: An abstract base test class that contains the actual test methods, which is getting extended by backend-specific test classes, which each contain a set of helper methods to access the raw storage (typically CRUD methods).
Second, I'd think that we can simply replace the service definition of path.alias_manager in
DUTB::containerBuild()
? We're doing the same for config.storage already. (I'm not sure why that special-casing for keyvalue exists and need to analyze that, but that's a separate issue) — Anyway, if any DUTB test needs the regular implementation for whatever reason, then it can override it back.Comment #10
dawehnerIt seems to be that using the Path object with another alias manager is the total wrong approach
Comment #12
Crell CreditAttribution: Crell commentedEr. Unless I'm misunderstanding something here we already have one. I added it as part of the CMF Routing patch so that I could unit test our generator. See Drupal\system\Tests\Routing\MockAliasManager.
It could probably be moved elsewhere to give it higher profile, but it works for unit testing. (See the other Mock classes in the same directory, too.)
Comment #13
dawehnerIf you compare the code at least MockAliasManager would fail hard on those tests.
Comment #14
Crell CreditAttribution: Crell commentedPerhaps; it was a quick-job to help test something else. Either way all we need is a simple mock object, and only one of them. So we should if nothing else have only one very-easy-to-configure-in-a-unit-test class at the end.
Comment #15
dawehnerSo i'm wondering whether the testLookupPath method should always just use the alias manager and not \Drupal\Core\Path\Path as that's trying to write to the database all the time.
Comment #16
dawehner. The approach in the tests seems wrong
Comment #17
jibran#10: drupal-1893730-9.patch queued for re-testing.
Comment #19
Crell CreditAttribution: Crell as a volunteer commentedI'm going to say this is sufficiently stale as to not be relevant anymore.