tests/src/Functional/CommentTest.php | 22 ++++++++++++++++++---- tests/src/Functional/NodeTest.php | 3 +-- tests/src/Functional/ResourceTestBase.php | 7 ------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/src/Functional/CommentTest.php b/tests/src/Functional/CommentTest.php index 0b9781a..e0eed4c 100644 --- a/tests/src/Functional/CommentTest.php +++ b/tests/src/Functional/CommentTest.php @@ -46,10 +46,6 @@ class CommentTest extends ResourceTestBase { */ protected static $patchProtectedFieldNames = [ 'status' => "The 'administer comments' permission is required.", - // @todo These are relationships, and cannot be tested in the same way. Fix in https://www.drupal.org/project/jsonapi/issues/2939810. - // 'pid' => NULL, - // 'entity_id' => NULL, - // 'uid' => NULL, 'name' => "The 'administer comments' permission is required.", 'homepage' => "The 'administer comments' permission is required.", 'created' => "The 'administer comments' permission is required.", @@ -57,6 +53,10 @@ class CommentTest extends ResourceTestBase { 'thread' => NULL, 'entity_type' => NULL, 'field_name' => NULL, + // @todo Uncomment this after https://www.drupal.org/project/drupal/issues/1847608 lands. Until then, it's impossible to test this. + // 'pid' => NULL, + 'entity_id' => NULL, + 'uid' => "The 'administer comments' permission is required.", ]; /** @@ -459,4 +459,18 @@ class CommentTest extends ResourceTestBase { return $cacheability; } + /** + * {@inheritdoc} + */ + public function testPatchIndividual() { + // Ensure ::getModifiedEntityForPatchTesting() can pick an alternative value + // for the 'entity_id' field. + EntityTest::create([ + 'name' => $this->randomString(), + 'type' => 'bar', + ])->save(); + + return parent::testPatchIndividual(); + } + } diff --git a/tests/src/Functional/NodeTest.php b/tests/src/Functional/NodeTest.php index 21074dd..6e2d2ce 100644 --- a/tests/src/Functional/NodeTest.php +++ b/tests/src/Functional/NodeTest.php @@ -49,13 +49,12 @@ class NodeTest extends ResourceTestBase { */ protected static $patchProtectedFieldNames = [ 'revision_timestamp' => NULL, - // @todo This is a relationship, and cannot be tested in the same way. Fix in https://www.drupal.org/project/jsonapi/issues/2939810. - // 'revision_uid' => NULL, 'created' => "The 'administer nodes' permission is required.", 'changed' => NULL, 'promote' => "The 'administer nodes' permission is required.", 'sticky' => "The 'administer nodes' permission is required.", 'path' => "The following permissions are required: 'create url aliases' OR 'administer url aliases'.", + 'revision_uid' => NULL, ]; /** diff --git a/tests/src/Functional/ResourceTestBase.php b/tests/src/Functional/ResourceTestBase.php index 068eecf..c10a454 100644 --- a/tests/src/Functional/ResourceTestBase.php +++ b/tests/src/Functional/ResourceTestBase.php @@ -2325,13 +2325,6 @@ abstract class ResourceTestBase extends BrowserTestBase { $field = $modified_entity->get($field_name); $original_values[$field_name] = $field->getValue(); switch ($field->getItemDefinition()->getClass()) { - case EntityReferenceItem::class: - // EntityReferenceItem::generateSampleValue() picks one of the last 50 - // entities of the supported type & bundle. We don't care if the value - // is valid, we only care that it's different. - $field->setValue(['target_id' => 99999]); - break; - case BooleanItem::class: // BooleanItem::generateSampleValue() picks either 0 or 1. So a 50% // chance of not picking a different value.