Problem/Motivation

We have no REST tests on CRUD for related entities like comments.

It's hard to find out how to POST a comment let alone fix for code changes breaking this again.

#2300827: How to POST a comment and other entities using entity references
#2394743: Comment REST Post fails on comment.statistics due to empty entity_type
#2430669: Cannot create comments from REST - field access is too strict

Proposed resolution

Let's write CRUD test for comment including a reply comment.

Remaining tasks

User interface changes

API changes

Comments

clemens.tolboom’s picture

Issue summary: View changes
clemens.tolboom’s picture

Status: Active » Needs review
StatusFileSize
new5.58 KB

Attached patch is an old attempt. Maybe a good starting point. Let's see what breaks.

Status: Needs review » Needs work

The last submitted patch, 2: add_tests_for_comments-2469581-2.patch, failed testing.

clemens.tolboom’s picture

  1. +++ b/core/modules/rest/src/Tests/CreateTest.php
    @@ -224,6 +235,53 @@ public function testCreateNode() {
    +      $entity_values['entity_id'] = $host_id;
    

    Does the host (resttest) content type supports comments?

  2. +++ b/core/modules/rest/src/Tests/RESTTestBase.php
    @@ -210,6 +210,14 @@ protected function entityValues($entity_type) {
    +          'entity_type' => 'node',
    

    This misses at least

     'field_name' => 'comment',
    
clemens.tolboom’s picture

Checking with \Drupal\comment\Tests\CommentItemTest it adds a comment field.

    $this->addDefaultCommentField('entity_test', 'entity_test', 'comment');
larowlan’s picture

Issue tags: +Needs reroll
larowlan’s picture

Assigned: Unassigned » larowlan

poking along

larowlan’s picture

Have this going, but going to close in favour of #2430669: Cannot create comments from REST - field access is too strict where the test will be needed (added) to show it is fixed.
@clemens.tolboom I'll ask a maintainer to add you to the commit credits over there

larowlan’s picture

Status: Needs work » Closed (duplicate)