Problem/Motivation

Discovered in #3569421: Remove remaining unnecessary uses of Formattable markup in tests that these methods are no longer used.

  • \Drupal\Tests\node\Functional\NodeTestBase::assertNodeAccess()
  • \Drupal\Tests\node\Functional\NodeTestBase::assertNodeCreateAccess()
  • \Drupal\Tests\node\Functional\NodeTestBase::nodeAccessAssertMessage()

Maybe these became used in #3041863: Convert a few node access tests from functional to kernel tests. In that issue both \Drupal\Tests\node\Kernel\NodeAccessTestBase::assertNodeAccess() and \Drupal\Tests\node\Kernel\NodeAccessTestBase::assertNodeCreateAccess() were created.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3608091

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

quietone created an issue. See original summary.

quietone’s picture

Issue summary: View changes

quietone’s picture

Status: Active » Needs review

No tests failed so setting for a review

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Seems a no brainer for core, question would be if contrib uses the assertions and if so, whether we want to keep supporting that. But anyway 2 out of 3 methods are marked internal.

godotislate’s picture

Access by Taxonomy in contrib uses assertNodeAccess quite a bit: https://git.drupalcode.org/project/access_by_taxonomy/-/blob/1.0.x/tests...

We could probably open an issue in that project. Since the core method is so small, it should be a straightforward fix.

godotislate’s picture

Title: Remove ununsed assertion methods in \Functional\NodeTestBase » Remove unused assertion methods in \Functional\NodeTestBase
needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

dcam’s picture

I'm the one who originally discovered the "dead" Functional assertions and suggested they might be deleted. I didn't think to check for contrib uses at the time. I double-checked #6 because that linked test base is a Kernel test and wouldn't be affected by the Functional assertion deletion. But Access By Taxonomy does implement it in other Functional tests, as does Domain Access per https://search.tresbien.tech/search?q=assertNodeAccess.

This discovery got me thinking about the issue. Maybe these assertions should be moved to a trait instead. The functions are only slightly out of sync: it looks like the assertEquals() expected/actual parameters were swapped in either the Functional or Kernel version at some point. If we do that, then we could have Functional\NodeTestBase implement the trait. That would be less disruptive for downstream code while still accomplishing a goal of eliminating duplicate code.

godotislate’s picture

I missed that the usages in Access by Taxonomy are in kernel tests. And looking at the search results again, all the results are in Kernel tests.

I think domain access is fine because they define their own assertNodeAccess method and do not inherit from core's. https://git.drupalcode.org/project/domain/-/blob/4147c874488175b546b4737...

If someone else can validate these two things, we can go back to RTBC after a rebase.

dcam’s picture

If someone else can validate these two things, we can go back to RTBC after a rebase.

Yes, you're right. I really thought that I saw a Functional test from Access By Taxonomy, but obviously got confused somewhere along the line. And Domain Access does implement its own function. I'm sorry for the noise.

So much for trying to be thorough.

dcam’s picture

Status: Needs work » Reviewed & tested by the community

I rebased it. Per #10 I'm setting it back to RTBC.

longwave’s picture

Status: Reviewed & tested by the community » Fixed

Dead code doesn't really harm anything so let's leave this in 11.x on the off chance someone is using them somewhere.

Committed and pushed 40680fe8869 to main. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed 40680fe8 on main
    test: #3608091 Remove unused assertion methods in \Functional\...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.