function NodeLegacyTest::testNodeSetRevisionAuthorId

Tests that Node::setRevisionAuthorId() triggers a deprecation error.

@expectedDeprecation Drupal\node\Entity\Node::setRevisionAuthorId is deprecated in drupal:8.2.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Entity\RevisionLogInterface::setRevisionUserId() instead. See https://www.drupal.org/node/3069750

File

core/modules/node/tests/src/Kernel/NodeLegacyTest.php, line 95

Class

NodeLegacyTest
Tests legacy user functionality.

Namespace

Drupal\Tests\node\Kernel

Code

public function testNodeSetRevisionAuthorId() {
    $user = $this->createUser([
        'uid' => 2,
        'name' => 'Test',
    ]);
    $entity = Node::create([
        'type' => 'page',
    ]);
    $entity->setRevisionAuthorId($user->id());
    $this->assertSame($user->id(), $entity->getRevisionUser()
        ->id());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.