diff --git a/core/modules/node/src/Tests/Views/RevisionLinkTest.php b/core/modules/node/src/Tests/Views/RevisionLinkTest.php index 177d0bc..37e52ac 100644 --- a/core/modules/node/src/Tests/Views/RevisionLinkTest.php +++ b/core/modules/node/src/Tests/Views/RevisionLinkTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\node\Tests\Views\RevisionLink. + * Contains \Drupal\node\Tests\Views\RevisionLinkTest. */ namespace Drupal\node\Tests\Views; @@ -10,7 +10,8 @@ /** * Tests the different revision link handlers. * - * @see \Drupal\node\Plugin\views\field\Revision + * @group node + * * @see \Drupal\node\Plugin\views\field\RevisionLink * @see \Drupal\node\Plugin\views\field\RevisionLinkDelete * @see \Drupal\node\Plugin\views\field\RevisionLinkRevert @@ -24,16 +25,12 @@ class RevisionLinkTest extends NodeTestBase { */ public static $testViews = array('test_node_revision_links'); + /** + * Test nodes. + * + * @var array + */ public $nodes = array(); - public $revisions = array(); - - public static function getInfo() { - return array( - 'name' => 'Node: Revision Links', - 'description' => 'Tests the different revision link handlers.', - 'group' => 'Views module integration', - ); - } /** * Tests revision links. @@ -44,63 +41,61 @@ public function testRevisionLinks() { $this->drupalCreateContentType(array('name' => 'page', 'type' => 'page')); $account = $this->drupalCreateUser(array('revert all revisions', 'view all revisions', 'delete all revisions', 'edit any page content', 'delete any page content')); $this->drupalLogin($account); - // Create two nodes, one without an additional revision and one with a // revision. - $this->nodes[] = $node = $this->drupalCreateNode(); - $this->revisions[] = $node; + $node = $this->drupalCreateNode(); + $this->nodes[] = $node; + $node = $this->drupalCreateNode(); + $this->nodes[] = $node; - $this->nodes[] = $node = $this->drupalCreateNode(); - $this->revisions[] = $node; - $node = clone $node; + $first_revision = $node->getRevisionId(); + // Create revision of the node. $node->setNewRevision(); - $this->revisions[] = $node; $node->save(); + $second_revision = $node->getRevisionId(); $this->drupalGet('test-node-revision-links'); $this->assertResponse(200, 'Test view can be accessed in the path expected'); - // The first node revision should link to the node directly as you get an // access denied if you link to the revision. - $path = $this->nodes[0]->getSystemPath(); - $this->assertLinkByHref($path); - $this->assertNoLinkByHref($path . '/revisions/' . $this->revisions[0]->getRevisionId() . '/delete'); - $this->assertNoLinkByHref($path . '/revision/' . $this->revisions[0]->getRevisionId() . '/revert'); + $url = $this->nodes[0]->urlInfo()->toString(); + $this->assertLinkByHref($url); + $this->assertNoLinkByHref($url . '/revisions/' . $this->nodes[0]->getRevisionId() . '/delete'); + $this->assertNoLinkByHref($url . '/revisions/' . $this->nodes[0]->getRevisionId() . '/revert'); // For the second node the current revision got set to the last revision, so // the first one should also link to the node page itself. - $path = $this->revisions[1]->getSystemPath(); - $this->assertLinkByHref($path . '/revisions/' . $this->revisions[1]->getRevisionId() . '/view'); - $this->assertLinkByHref($path . '/revisions/' . $this->revisions[1]->getRevisionId() . '/delete'); - $this->assertLinkByHref($path . '/revisions/' . $this->revisions[1]->getRevisionId() . '/revert'); + $url = $this->nodes[1]->urlInfo()->toString(); + $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/view'); + $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/delete'); + $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/revert'); - $path = $this->revisions[2]->getSystemPath(); - $this->assertLinkByHref($path); - $this->assertNoLinkByHref($path . '/revisions/' . $this->revisions[2]->getRevisionId() . '/delete'); - $this->assertNoLinkByHref($path . '/revisions/' . $this->revisions[2]->getRevisionId() . '/revert'); + $this->assertLinkByHref($url); + $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/view'); + $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/delete'); + $this->assertNoLinkByHref($url . '/revisions/' . $second_revision . '/revert'); $accounts = array(); $accounts['view'] = $this->drupalCreateUser(array('view all revisions')); $accounts['revert'] = $this->drupalCreateUser(array('revert all revisions', 'edit any page content')); $accounts['delete'] = $this->drupalCreateUser(array('delete all revisions', 'delete any page content')); - $operations = array_keys($accounts); array_shift($operations); - $path = $this->revisions[1]->getSystemPath(); + $url = $this->nodes[1]->urlInfo()->toString(); // Render the view with users which can only delete/revert revisions. foreach ($accounts as $op => $account) { $this->drupalLogin($account); $this->drupalGet('test-node-revision-links'); - // Check expected links. foreach ($operations as $operation) { if ($operation == $op) { - $this->assertLinkByHref($path . '/revisions/' . $this->revisions[1]->getRevisionId() . '/' . $operation); + $this->assertLinkByHref($url . '/revisions/' . $first_revision . '/' . $operation); } else { - $this->assertNoLinkByHref($path . '/revisions/' . $this->revisions[1]->getRevisionId() . '/' . $operation); + $this->assertNoLinkByHref($url . '/revisions/' . $first_revision . '/' . $operation); } } } } + } diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_links.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_links.yml index fc5c06e..1313f01 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_links.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_links.yml @@ -1,4 +1,4 @@ -langcode: und +langcode: en status: true dependencies: module: @@ -16,8 +16,11 @@ display: display_plugin: default id: default display_title: Master - position: 1 + position: 0 display_options: + access: + type: none + options: { } cache: type: none options: { } @@ -26,6 +29,7 @@ display: options: disable_sql_rewrite: false distinct: false + replica: false query_comment: '' query_tags: { } exposed_form: @@ -50,12 +54,12 @@ display: fields: link_to_revision: id: link_to_revision - table: node_revision + table: node_field_revision field: link_to_revision relationship: none group_type: group admin_label: '' - label: 'Link to revision' + label: '' exclude: false alter: alter_text: false @@ -74,7 +78,7 @@ display: suffix: '' target: '' nl2br: false - max_length: 1 + max_length: 0 word_boundary: true ellipsis: true more_link: false @@ -88,7 +92,7 @@ display: element_class: '' element_label_type: '' element_label_class: '' - element_label_colon: true + element_label_colon: false element_wrapper_type: '' element_wrapper_class: '' element_default_classes: true @@ -96,16 +100,17 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - text: '' + text: 'Link to revision' + entity_type: node plugin_id: node_revision_link delete_revision: id: delete_revision - table: node_revision + table: node_field_revision field: delete_revision relationship: none group_type: group admin_label: '' - label: 'Link to delete revision' + label: '' exclude: false alter: alter_text: false @@ -124,7 +129,7 @@ display: suffix: '' target: '' nl2br: false - max_length: 1 + max_length: 0 word_boundary: true ellipsis: true more_link: false @@ -138,7 +143,7 @@ display: element_class: '' element_label_type: '' element_label_class: '' - element_label_colon: true + element_label_colon: false element_wrapper_type: '' element_wrapper_class: '' element_default_classes: true @@ -146,16 +151,17 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - text: '' + text: 'Link to delete revision' + entity_type: node plugin_id: node_revision_link_delete revert_revision: id: revert_revision - table: node_revision + table: node_field_revision field: revert_revision relationship: none group_type: group admin_label: '' - label: 'Link to revert revision' + label: '' exclude: false alter: alter_text: false @@ -174,7 +180,7 @@ display: suffix: '' target: '' nl2br: false - max_length: 1 + max_length: 0 word_boundary: true ellipsis: true more_link: false @@ -188,7 +194,7 @@ display: element_class: '' element_label_type: '' element_label_class: '' - element_label_colon: true + element_label_colon: false element_wrapper_type: '' element_wrapper_class: '' element_default_classes: true @@ -196,7 +202,8 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - text: '' + text: 'Link to delete revision' + entity_type: node plugin_id: node_revision_link_revert filters: { } sorts: { } @@ -207,14 +214,11 @@ display: relationships: { } arguments: { } display_extenders: { } - filter_groups: - operator: AND - groups: { } page_1: display_plugin: page id: page_1 display_title: Page position: 1 display_options: - path: test-node-revision-links display_extenders: { } + path: test-node-revision-links