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 Feed 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 |
---|---|---|---|
#43 | entityresource_provide-2843754-43.patch | 11.78 KB | Wim Leers |
#33 | interdiff-31-33.txt | 1.74 KB | rogierbom |
#33 | entityresource_provide-2843754-33.patch | 11.23 KB | rogierbom |
#31 | interdiff-26-31.txt | 3.08 KB | rogierbom |
#31 | entityresource_provide-2843754-31.patch | 11.28 KB | rogierbom |
Comments
Comment #3
rogierbom CreditAttribution: rogierbom at Synetic commentedComment #4
Wim LeersComment #5
rogierbom CreditAttribution: rogierbom at Synetic commentedComment #6
Wim LeersWoot!
This looks excellent. I only have nitpicks :)
Needs
\n
in between.Let's use
example.com
instead oflocalhost
. When reading this, you might mistakenly think that this is referencing a Drupal URL.Also,
setUrl
is the feed URL. So it should behttp://example.com/rss.xml
. AndsetWebsiteUrl()
is the feed's website URL. So,http://example.com
in this case.Let's make these have different values.
Unused, can be deleted :)
Comment #7
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commentedComment #8
Wim Leers@gaurav.kapoor: this issue is A) assigned to somebody, B) that somebody is at a Drupal sprint event. It's not cool to jump in here and do rerolls. That looks like issue credit mining, and is extremely annoying ;)
Comment #9
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commented@wimleers i just did the minor fixes which will help in solving this quickly. They didn't require much time. There wasn't any activity from 7-8 hours on this issue. I don't want any credit for this issue.Thanks.
Comment #11
Wim LeersOkay. Sorry then. But there wasn't activity for 7-8 hours … because this was posted very late (almost 1 AM), after which people went to sleep. Not working for 7-8 hours for resting is not unreasonable I think.
Comment #12
rogierbom CreditAttribution: rogierbom at Synetic commentedUhm, yes... I was actually just getting some sleep before continuing...
Comment #13
rogierbom CreditAttribution: rogierbom at Synetic commentedPrevious patch actually broke the test. Also part of remark .2 in #6 was missed.
Comment #15
Wim LeersLooks much better :)
Comment #16
Anonymous (not verified) CreditAttribution: Anonymous commentedYeah! And looks like we need only a few bit steps to absolutely best:
'url'
value ingetNormalizedPostEntity
, eg:'title'
and'url'
, because during the testing Feed created several times, and these fields must be unique (see random postfix in prev point)'image'
ingetNormalizedPostEntity
, maybe also like 'internal:/image' (it needs toPATCH
).]
in short array.Comment #17
Wim LeersFor
testPatch()
we're getting the following unexpected error output:i.e. the
url.0.value
andimage.0.value
values are incomplete.So, I did some debugging. Turns out it is because you're still passing relative URLs as the feed URL and the image URL. This causes
\Drupal\Core\Validation\Plugin\Validation\Constraint\PrimitiveTypeConstraintValidator::validate()
to trigger/add a constraint violation. Those should be actual URLs.Comment #18
Wim LeersNow
testPatch()
passes.testPost()
gets further, but it fails on the very last assertion. The response is a 422 instead of a 201, with this response body:This is because
Feed
, unlike every other entity type has aFeedTitle
constraint that requires titles to be unique. Which causes the existing generic test coverage to fail with the above error.Comment #21
Wim Leers#18 is green, yay! :) What we still need now, is HAL test coverage.
There's also @vaplas' review in #16. I addressed some of that already:
internal:
URIs. We want an actual feed you can fetch. Which pretty much by definition is an "external" feed. Otherwise we're aggregating our own content :)image
is necessary for POSTing? It's not a required field. (In fact, it's populated automatically upon fetching a feed for the first time!)So only points 4 and 5 of #16 still need to be addressed.
Comment #22
Wim LeersI contacted @rogierbom :)
Comment #23
Anonymous (not verified) CreditAttribution: Anonymous commentedThank you for review @Wim Leers!
I pointed to the problem with PATCH:
But your magical change solves this problem too, of course! In all other points of #16 I fooled even more :)
So yes, only points 4 and 5 of #16.
Comment #24
Wim Leers@rogierbom replied to my e-mail: he said he was going to look at this again in the next few days.
Comment #25
rogierbom CreditAttribution: rogierbom at Synetic commentedI cleaned up the short arrays, working on the HAL tests right now.
Comment #26
rogierbom CreditAttribution: rogierbom at Synetic commentedDoh, removed one comma to many...
Comment #27
Wim LeersYou forgot to mark it
, which is why #25 and #26 are not being tested :)Comment #28
Wim LeersYou forgot to add the
HAL
tests. So\Drupal\Tests\hal\Functional\EntityResource\Feed\FeedHalJsonBasicAuthTest
and so on.Comment #29
rogierbom CreditAttribution: rogierbom at Synetic commented@Wim: I didn't forget them, I'm still working on them ;-)
Comment #30
Wim LeersOh, cool :) I only noticed seconds before I marked this issue RTBC :P
Comment #31
rogierbom CreditAttribution: rogierbom as a volunteer and at Synetic commentedTook a while because of a busy period at work, but here's a re-roll including HAL tests.
Comment #32
Wim Leers#31: no problem :) Thanks for posting this!
There are some small problems in your last patch:
We don't want this
@group
annotation: that'd cause PHPUnit to try to run this as a test if you usephp vendor/bin/phpunit -c core --group hal
. But it's a base class. So it will fail.The first line is indented correctly. All subsequent lines are indented too much: they have 2 extraneous leading spaces.
Once those are fixed, this is RTBC!
Comment #33
rogierbom CreditAttribution: rogierbom as a volunteer and at Synetic commentedRe-roll with fixes for Wim's remarks in #32
Comment #34
Wim LeersHeh, #31 failed because of #32.1 :)
This patch looks perfect! Thanks, @rogierbom! :)
Comment #35
MiSc CreditAttribution: MiSc at Wunder commentedPatch still applies to 8.4.x-dev
Comment #37
Wim LeersComment #38
Wim LeersThis is blocking #2835845 per #2835845-17: EntityResource: Provide comprehensive test coverage for BlockContent entity.
Comment #39
alexpottThis is a subtle change to all the other tests. It was added in #18 because of the unique constraint. It changes the amount of entities that will exist as a result of running testPost. It might be okay. Not sure - going to think about it. Leaving at RTBC.
Comment #40
Wim LeersYes, it is okay.
Comment #42
alexpottDrupal\Tests\hal\Functional\EntityResource\Feed\FeedHalJsonTestBase is failing.
Comment #43
Wim LeersOh hm… this is interesting. When I applied the #33 patch locally (on a branch where I also have other changes), it applied it to the wrong hunk… but when I'm back on HEAD and apply the patch in #33 again, it does apply to the correct hunk.
Why is this even possible? Because there are two very similar-looking hunks:
git appears to not include enough context to be able to unambiguously apply this. Rerolled patch, with interdiff to show what I changed in the locally+wrongly applied patch from #3. But note that #33 contains this:
whereas this contains:
It's interesting that we're effectively running into a
git diff
orgit apply
bug here! That's a first :)Comment #44
alexpottCommitted and pushed 2dc6d91 to 8.4.x and 4d67f1b to 8.3.x. Thanks!
Fixed coding standards on commit.
Comment #47
Wim LeersYay!
Comment #48
Wim Leers#2835845: EntityResource: Provide comprehensive test coverage for BlockContent entity is now unblocked :)