Closed (fixed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
rest.module
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
16 Jan 2017 at 05:55 UTC
Updated:
12 Apr 2017 at 11:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
shadcn commentedWorking on this one instead since #2843755: EntityResource: Provide comprehensive test coverage for Message entity is currently blocked :)
Comment #4
wim leersWoot, thanks! :)
Comment #5
shadcn commentedI'm attaching a WIP patch here.
It's failing because
\Drupal\aggregator\Entity\Itemhas no canonical url but still returnstext/html; charset=UTF-8. Hence the test below fails:Here's a related issue with some more info: #2853211: EntityResource::post() incorrectly assumes that every entity type has a canonical URL.
Wim, can you advise on how to fix the fails here? Thanks.
Note: I've marked
testPatchandtestPatchas skipped for now.Comment #7
wim leersGreat catch!
We're in
testPost(), yet the code said this:Note the mention of
"GET"!That does not make sense. I mirrorred this after
testGet(). But of course that doesn't make sense. When you don't specify a format, thenhtmlis assumed by Drupal. Hence, you'll always get a HTML response.A similar problem exists a dozen lines of code further down.
I fixed both of those. Now you're getting this error:
I'll leave that to you again :)
Comment #9
shadcn commentedThanks @Wim Leers. This is super helpful.
Comment #10
shadcn commentedAdding another WIP patch here. This one fails (see the fail for testPost) because
\Drupal\aggregator\Entity\Itemhas no uuid.Which is a good thing because now we can write the tests for #2835576: InvalidArgumentException: Field uuid is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField().
Comment #11
shadcn commentedComment #12
shadcn commentedComment #14
shadcn commented@Wim Leers I believe we will have the same issues in #7 for
testPatchandtestDelete?Should we fix it in the related ticket here: #2853211: EntityResource::post() incorrectly assumes that every entity type has a canonical URL? I've updated the title of the ticket.
Comment #15
shadcn commentedComment #16
wim leers#10 + #12:
\Drupal\aggregator\Entity\Item::baseFieldDefinitions():I just got that issue going again: #2149851-14: Remove todo about GUID field on the 'aggregator_item' entity and add UUID field. If
Itementities behaved as intended, then this would be a non-issue.Itementities. So I'd rather not have that committed, and would prefer #2149851: Remove todo about GUID field on the 'aggregator_item' entity and add UUID field to be fixed instead.#14 + #15:
Indeed.
I think so, yes. Posted a review there!
Comment #17
wim leers#2853211: EntityResource::post() incorrectly assumes that every entity type has a canonical URL landed, this is now unblocked!
Comment #18
shadcn commentedThanks @Wim Leers. Working on it now.
Comment #19
wim leersWoot, thanks!
Comment #20
shadcn commentedOK let's try this one.
Note: I added a check for the uuid field and a @todo with a link to the issue. Let me know if this works.
Comment #22
shadcn commentedForgot to include the EntityResourceTestBase fix. Let's try again.
Comment #23
wim leersSo close!
We should change this to:
That's more explicit.
s/array()/[]/
We can hardcode this ID to
1AFAICT?Comment #24
shadcn commentedUpdated. Thanks @Wim Leers :)
Comment #25
wim leersSorry… I noticed a few more small things:
Let's omit the
t()call here.t()is for interface translation. This is content.Why use
setPostedTime(), but notsetFeedId(),setTitle()orsetLink()?Let's use those setters instead of passing all the values in the
Item::create()call. That's better/clearer.(It's also how e.g.
\Drupal\Tests\rest\Functional\EntityResource\Node\NodeResourceTestBase::createEntity()does it.)We can even hardcode this URL! :)
After this, I promise it's RTBC!
Comment #26
shadcn commentedAll changes completed.
Comment #27
wim leersThanks!
Comment #29
wim leersAhhh, this only works on D8 installations that are installed in a domain's root, it will fail for subdir installations.
Use
base_path()here. See e.g.\Drupal\Tests\rest\Functional\EntityResource\Comment\CommentResourceTestBase::getExpectedNormalizedEntity().Comment #30
shadcn commentedUpdated.
Comment #31
wim leersComment #32
alexpottCommitted and pushed 8419d5e to 8.4.x and 769eb4b to 8.3.x. Thanks!
Comment #35
wim leers#2857086: EntityResourceTestBase: only test uuid for entity types that have uuid was closed as a duplicate of this :)