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.
Over in #2737729: Canonical and AMPHTML must be absolute we changed amphtml links to be absolute rather than relative. Now we need to update the test in tests/src/Functional/AmpFormatterTest.php.
Comment | File | Size | Author |
---|---|---|---|
#6 | interdiff-2741217-6.txt | 1.17 KB | mtift |
#6 | amp-test-absolute-urls-2741217-6.patch | 1.87 KB | mtift |
Comments
Comment #2
mtiftThis feels very hacky to me, but I couldn't figure out a better way to test for
link rel="amphtml" href="http://amp.dev/node/1?amp"
rather than
link rel="amphtml" href="http://amp.dev/node/1?amp=1"
without resorting to doing this (or some other string manipulation):
I'm certainly open to other suggestions. But this works and the tests pass (again).
Comment #3
mtiftComment #4
BerdirIt's not pretty either, but why don't you just use the same hack as when we generate the url in the code? generate it without the query, then append it. We know that there's nothing else in the test anyway..
But I'll ask @dawehner about this.
I noticed a similar same problem with e.g. redirect.module redirects (when aliases change..) then the resulting url is ?amp= and amp validator is unhappy about the difference between actual url and amphtml link on the canonical page...
Comment #5
dawehnerJust use => NULL:
Comment #6
mtiftThanks for your input, @dawehner. However, if I use NULL, like this:
Then it does not set any parameters and the tests fail with this message:
I'm fine with appending. That's probably more straightforward.
Comment #7
dawehnerOh yeah, that is clearly a bug of core: #2741617: The URL generator doesn't allow to use no query parameter value
Comment #8
RainbowArrayGood to see #2741617: The URL generator doesn't allow to use no query parameter value looks like it will make testing this more doable. Probably makes sense to postpone this fix until that lands in core. The alternative is doing something less ideal now, than leaving a @todo for after this gets in. Fine with that, too, but setting this to postponed to start. Feel free to change if you prefer mtift.
Comment #9
mtiftNo, I don't think this should be postponed, because without this patch our tests are breaking. I suggest we commit this code and open an follow-up.
Comment #10
mtiftHere's the follow-up: #2745187: Update tests to use use NULL query parameter value
Comment #11
RainbowArrayCode looks good, tested the test, that seems to run fine. RTBC.
Comment #13
mtiftCommitted to 8.x-1.x. Thanks, all!
Comment #15
mtift