Verified Commit ef4dc872 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3323260 by Spokje, longwave: Remove usage of node_revision_load() and friends

parent 3ca98df3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ public function testRevisions() {
    $this->assertFileIsPermanent($node_file_r2, 'Replacement file is permanent.');

    // Check that the original file is still in place on the first revision.
    $node = node_revision_load($node_vid_r1);
    $node = $node_storage->loadRevision($node_vid_r1);
    $current_file = File::load($node->{$field_name}->target_id);
    $this->assertEquals($node_file_r1->id(), $current_file->id(), 'Original file still in place after replacing file in new revision.');
    $this->assertFileExists($node_file_r1->getFileUri());
+4 −4
Original line number Diff line number Diff line
@@ -637,7 +637,7 @@ public function testDeleteRespectsUserCancelBlock() {
    $test_node = $node_storage->load($node->id());
    $this->assertNotNull($test_node, 'Node of the user is not deleted.');
    $this->assertTrue($test_node->isPublished(), 'Node of the user is published.');
    $test_node = node_revision_load($node->getRevisionId());
    $test_node = $node_storage->loadRevision($node->getRevisionId());
    $this->assertTrue($test_node->isPublished(), 'Node revision of the user is published.');
  }

@@ -667,7 +667,7 @@ public function testDeleteRespectsUserCancelBlockUnpublish() {
    $test_node = $node_storage->load($node->id());
    $this->assertNotNull($test_node, 'Node of the user is not deleted.');
    $this->assertFalse($test_node->isPublished(), 'Node of the user is no longer published.');
    $test_node = node_revision_load($node->getRevisionId());
    $test_node = $node_storage->loadRevision($node->getRevisionId());
    $this->assertFalse($test_node->isPublished(), 'Node revision of the user is no longer published.');
  }

@@ -713,7 +713,7 @@ public function testDeleteRespectsUserCancelBlockUnpublishAndProcessesBatches()
    }

    foreach ($nodes as $node) {
      $test_node = node_revision_load($node->getRevisionId());
      $test_node = $node_storage->loadRevision($node->getRevisionId());
      $this->assertFalse($test_node->isPublished(), 'Node revision of the user is no longer published.');
    }
  }
@@ -744,7 +744,7 @@ public function testDeleteRespectsUserCancelReassign() {
    $this->assertNotNull($test_node, 'Node of the user is not deleted.');
    $this->assertTrue($test_node->isPublished(), 'Node of the user is still published.');
    $this->assertEquals(0, $test_node->getOwnerId(), 'Node of the user has been attributed to anonymous user.');
    $test_node = node_revision_load($node->getRevisionId());
    $test_node = $node_storage->loadRevision($node->getRevisionId());
    $this->assertTrue($test_node->isPublished(), 'Node revision of the user is still published.');
    $this->assertEquals(0, $test_node->getRevisionUser()->id(), 'Node revision of the user has been attributed to anonymous user.');
  }
+1 −1
Original line number Diff line number Diff line
@@ -181,7 +181,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
    parent::postSave($storage, $update);

    if ($update && $this->getOriginalId() != $this->id()) {
      $update_count = node_type_update_nodes($this->getOriginalId(), $this->id());
      $update_count = $storage->updateType($this->getOriginalId(), $this->id());
      if ($update_count) {
        \Drupal::messenger()->addStatus(\Drupal::translation()->formatPlural($update_count,
          'Changed the content type of 1 post from %old-type to %type.',
+3 −2
Original line number Diff line number Diff line
@@ -126,8 +126,9 @@ public function testNodeEdit() {
    $this->assertSame($node->getOwnerId(), $revised_node->getOwnerId(), 'The node author has been preserved.');
    // Ensure that the revision authors are different since the revisions were
    // made by different users.
    $first_node_version = node_revision_load($node->getRevisionId());
    $second_node_version = node_revision_load($revised_node->getRevisionId());
    $node_storage = \Drupal::service('entity_type.manager')->getStorage('node');
    $first_node_version = $node_storage->loadRevision($node->getRevisionId());
    $second_node_version = $node_storage->loadRevision($revised_node->getRevisionId());
    $this->assertNotSame($first_node_version->getRevisionUser()->id(), $second_node_version->getRevisionUser()->id(), 'Each revision has a distinct user.');

    // Check if the node revision checkbox is rendered on node edit form.
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +161,7 @@ public function testRevisions() {
    $this->assertNotSame($this->revisionUser->id(), $reverted_node->getRevisionUserId(), 'Node revision author is not original revision author.');

    // Confirm that this is not the current version.
    $node = node_revision_load($node->getRevisionId());
    $node = $node_storage->loadRevision($node->getRevisionId());
    $this->assertFalse($node->isDefaultRevision(), 'Third node revision is not the current one.');

    // Confirm that the node can still be updated.
Loading