Follow-up to #2555899: Add test coverage for Comment link handlers handler

Problem/Motivation

\Drupal\node\Plugin\views\field\RevisionLink, \Drupal\node\Plugin\views\field\RevisionLinkDelete and \Drupal\node\Plugin\views\field\RevisionLinkRevert have no test coverage at the moment

Proposed resolution

Add test coverage

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because we are just adding tests
Issue priority Normal because we are adding tests for something small that works but just didn't have test coverage.
Unfrozen changes Unfrozen because it only adds tests.

Comments

geertvd created an issue. See original summary.

geertvd’s picture

StatusFileSize
new5.46 KB
geertvd’s picture

This is going to fail because I can't figure out how to reset the $access property in NodeRevisionAccessCheck.

Status: Needs review » Needs work

The last submitted patch, 2: 2567215-2.patch, failed testing.

The last submitted patch, 2: 2567215-2.patch, failed testing.

dawehner’s picture

This is going to fail because I can't figure out how to reset the $access property in NodeRevisionAccessCheck.

If you really want to be evil you can do the following:

use \Drupal\node\Access\NodeRevisionAccessCheck;
$reflection_class = new \ReflectionClass(NodeRevisionAccessCheck::class);
$reflection_property = $reflection_class->getProperty('access');
$reflection_property->setAccessible(TRUE);
$reflection_property->setValue([]);
geertvd’s picture

Status: Needs work » Needs review
StatusFileSize
new5.95 KB
new1.16 KB

That fixes it. Not sure if this is to evil for core :)

dawehner’s picture

+++ b/core/modules/node/src/Tests/Views/NodeRevisionLinksTest.php
@@ -110,6 +111,14 @@ public function testRevisionLinkHandlers() {
+    // Clearing the access property of NodeRevisionAccessCheck like this since
+    // I can't do a page refresh.
+    $reflection_class = new \ReflectionClass(NodeRevisionAccessCheck::class);
+    $reflection_property = $reflection_class->getProperty('access');
+    $reflection_property->setAccessible(TRUE);
+    $node_revision_access = \Drupal::service('access_check.node.revision');
+    $reflection_property->setValue($node_revision_access, []);

Well yeah another possibility is to reset the service on the container, but well, not sure which approach is actually nicer!

geertvd’s picture

I would have thought $this->container->set('access_check.node.revision', NULL); would work also but it doesn't.
Am I doing something wrong there?

lokapujya’s picture

see https://www.drupal.org/node/1863898. It has tests for D8, so maybe they can be combined.

lokapujya’s picture

no_angel’s picture

Assigned: Unassigned » no_angel
no_angel’s picture

Assigned: no_angel » Unassigned

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Version: 9.4.x-dev » 10.1.x-dev
Status: Needs review » Needs work

Needs updating for 10.1

With the addition of https://www.drupal.org/project/drupal/issues/2350939 wonder if this should be done differently.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley’s picture