diff core/modules/node/tests/src/Functional/NodeRevisionsTest.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
line wrap: on
line diff
--- a/core/modules/node/tests/src/Functional/NodeRevisionsTest.php	Thu Feb 28 13:11:55 2019 +0000
+++ b/core/modules/node/tests/src/Functional/NodeRevisionsTest.php	Thu May 09 15:34:47 2019 +0100
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\node\Functional;
 
+use Drupal\Core\Database\Database;
 use Drupal\Core\Url;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
@@ -163,7 +164,7 @@
     $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
       '@type' => 'Basic page',
       '%title' => $nodes[1]->label(),
-      '%revision-date' => format_date($nodes[1]->getRevisionCreationTime()),
+      '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
     ]), 'Revision reverted.');
     $node_storage->resetCache([$node->id()]);
     $reverted_node = $node_storage->load($node->id());
@@ -180,17 +181,18 @@
     // Confirm revisions delete properly.
     $this->drupalPostForm("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", [], t('Delete'));
     $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', [
-      '%revision-date' => format_date($nodes[1]->getRevisionCreationTime()),
+      '%revision-date' => $this->container->get('date.formatter')->format($nodes[1]->getRevisionCreationTime()),
       '@type' => 'Basic page',
       '%title' => $nodes[1]->label(),
     ]), 'Revision deleted.');
+    $connection = Database::getConnection();
     $this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid and vid = :vid', [':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()])->fetchField() == 0, 'Revision not found.');
     $this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid and vid = :vid', [':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()])->fetchField() == 0, 'Field revision not found.');
 
     // Set the revision timestamp to an older date to make sure that the
     // confirmation message correctly displays the stored revision date.
     $old_revision_date = REQUEST_TIME - 86400;
-    db_update('node_revision')
+    $connection->update('node_revision')
       ->condition('vid', $nodes[2]->getRevisionId())
       ->fields([
         'revision_timestamp' => $old_revision_date,
@@ -200,7 +202,7 @@
     $this->assertRaw(t('@type %title has been reverted to the revision from %revision-date.', [
       '@type' => 'Basic page',
       '%title' => $nodes[2]->label(),
-      '%revision-date' => format_date($old_revision_date),
+      '%revision-date' => $this->container->get('date.formatter')->format($old_revision_date),
     ]));
 
     // Make a new revision and set it to not be default.
@@ -222,7 +224,7 @@
 
     // Verify that the non-default revision vid is greater than the default
     // revision vid.
-    $default_revision = db_select('node', 'n')
+    $default_revision = $connection->select('node', 'n')
       ->fields('n', ['vid'])
       ->condition('nid', $node->id())
       ->execute()
@@ -237,6 +239,17 @@
     $node->save();
 
     $this->drupalGet("node/" . $node->id() . "/revisions");
+    // Verify revisions is accessible since the type has revisions enabled.
+    $this->assertResponse(200);
+    // Check initial revision is shown on the node revisions overview page.
+    $this->assertText('Simple revision message (EN)');
+
+    // Verify that delete operation is inaccessible for the default revision.
+    $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/delete");
+    $this->assertResponse(403);
+
+    // Verify that revert operation is inaccessible for the default revision.
+    $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/revert");
     $this->assertResponse(403);
 
     // Create a new revision and new log message.
@@ -259,7 +272,10 @@
     $node->save();
 
     $this->drupalGet("node/" . $node->id() . "/revisions");
-    $this->assertResponse(403);
+    // Verify revisions is accessible since the type has revisions enabled.
+    $this->assertResponse(200);
+    // Check initial revision is shown on the node revisions overview page.
+    $this->assertText('Simple revision message (EN)');
 
     // Add a translation in 'DE' and create a new revision and new log message.
     $translation = $node->addTranslation('de');