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/Motivation
Please refer the problem/motivation section of #2737719: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method
Proposed resolution
Write EntityResourceTestBase subclass for the ContactForm entity.
Remaining tasks
References
1. Follow-up of #2737719: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method
2. Subtask of #2824572: Write EntityResourceTestBase subclasses for every other entity type.
Comment | File | Size | Author |
---|---|---|---|
#20 | 2843778-20.patch | 11.77 KB | Wim Leers |
Comments
Comment #2
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedComment #4
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedComment #5
sumanthkumarc CreditAttribution: sumanthkumarc at Azri Solutions commentedComment #6
benelori CreditAttribution: benelori commentedComment #7
Wim Leers@benelori: thanks for taking this on! :)
Comment #8
naveenvalechaAssigning to myself to take this up.
Comment #9
Wim LeersThanks @naveenvalecha!
Comment #10
Wim LeersComment #12
Wim LeersHere's the needed test coverage.
Comment #13
Wim LeersTurns out that
\Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::getEntityResourceUrl()
is inadequate, and this has gone unnoticed for a long time.Turns out
ContactForm
is the only@ConfigEntityType
in Drupal core that specifies acanonical
link template. This is why we're only finding this now!That method does this:
Simple enough, right? But …
ConfigEntityBase
overrides thetoUrl()
method:Which means that we were getting the
edit-form
URL instead of thecanonical
URL, even when we know a canonical URL exists. Fortunately, this is easy to fix.Comment #14
Wim LeersThe above patch almost passes — the only thing that's missing is the expected helpful messages for 403 responses. Fortunately, this too is trivial fix 😀
Comment #16
Wim LeersAdded HAL+JSON test coverage.
Now ready for final review.
Comment #18
Anonymous (not verified) CreditAttribution: Anonymous commentedReally nice correction! 💎
all other just nice ;)
https://www.drupal.org/pift-ci-job/753333 - it seems CI also really likes this patch <3333
Comment #19
larowlanI'd like to see some coverage around the recipients field, particularly for the multi-value instance (comma separated). But that can be in the existing follow-up. It's a bit of a snowflake in so far as we're cramming multiple values into a single field.
I think a comment here to explain the findings in #13 would help - and probably prevent someone thinking that the 'canonical' argument was superfluous. I thought it was at first. Knocking back to needs work for that (docs gate), but will keep an eye out for when this gets back to RTBC so it doesn't sink to bottom of list.
Comment #20
Wim Leers@ContactForm
entity form. When you save that form, it stores them as a list of strings. (I tested manually to verify.) Test coverage added!Comment #23
larowlanCommitted as a87e8aa and pushed to 8.5.x.
Cherrypicked as 3d0abda and pushed to 8.4.x.
Thanks @WimLeers et al