You are here

protected function RESTTestBase::removeNodeFieldsForNonAdminUsers in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/rest/src/Tests/RESTTestBase.php \Drupal\rest\Tests\RESTTestBase::removeNodeFieldsForNonAdminUsers()

Remove node fields that can only be written by an admin user.

Parameters

\Drupal\node\NodeInterface $node: The node to remove fields where non-administrative users cannot write.

Return value

\Drupal\node\NodeInterface The node with removed fields.

1 call to RESTTestBase::removeNodeFieldsForNonAdminUsers()
CreateTest::testCreateNode in core/modules/rest/src/Tests/CreateTest.php
Tests several valid and invalid create requests for 'node' entity type.

File

core/modules/rest/src/Tests/RESTTestBase.php, line 384
Contains \Drupal\rest\Tests\RESTTestBase.

Class

RESTTestBase
Test helper class that provides a REST client method to send HTTP requests.

Namespace

Drupal\rest\Tests

Code

protected function removeNodeFieldsForNonAdminUsers(NodeInterface $node) {
  $node
    ->set('status', NULL);
  $node
    ->set('created', NULL);
  $node
    ->set('changed', NULL);
  $node
    ->set('promote', NULL);
  $node
    ->set('sticky', NULL);
  $node
    ->set('revision_timestamp', NULL);
  $node
    ->set('revision_log', NULL);
  $node
    ->set('uid', NULL);
  return $node;
}