Add tests for reverting revisions to check authorship
2 unresolved threads
2 unresolved threads
Closes #1528028
Merge request reports
Activity
55 $revisedRevisionId = $node->getRevisionId(); 56 57 $nodeStorage = \Drupal::entityTypeManager()->getStorage('node'); 58 59 // Confirm that in the revised node, $user3 is the author and $user2 is 60 // the revision user. 61 self::assertEquals($node->getOwnerId(), $initialRevisionAuthor->id()); 62 self::assertEquals($node->getRevisionUserId(), $initialRevisionUser->id()); 63 64 // Revert to the original node revision. 65 $this->drupalGet(Url::fromRoute('node.revision_revert_confirm', [ 66 'node' => $node->id(), 67 'node_revision' => $originalRevisionId, 68 ])); 69 $this->submitForm([], 'Revert'); 70 $this->assertSession()->pageTextContains(\sprintf('Basic page %s has been reverted', $originalTitle)); There is an coding standard issue about the use of sprintf, [#3118957] but that is still open. So, that doesn't offer guidance. But we should make sure that its usage is readable.
- Resolved by Adam Bramley
74 $nodeStorage->resetCache([$node->id()]); 75 /** @var \Drupal\node\NodeInterface $revertedNode */ 76 $revertedNode = $nodeStorage->load($node->id()); 77 self::assertEquals($originalBody, $revertedNode->body->value); 78 self::assertEquals($initialUser->id(), $revertedNode->getOwnerId()); 79 self::assertEquals($initialUser->id(), $revertedNode->getRevisionUserId()); 80 81 // Revert again to the revised version and check that node author and 82 // revision author fields are correct. 83 // Revert to the original node. 84 $this->drupalGet(Url::fromRoute('node.revision_revert_confirm', [ 85 'node' => $revertedNode->id(), 86 'node_revision' => $revisedRevisionId, 87 ])); 88 $this->submitForm([], 'Revert'); 89 $this->assertSession()->pageTextContains(\sprintf('Basic page %s has been reverted', $revisedTitle));
Please register or sign in to reply