When the HAL module was moved out of core, the test for DBLogResource was also moved, because it uses the HAL module. This move of the test case was done in #3263654: Move all HAL tests to the module in preparation of removal in D10. The assumption seems to be that because the test used "hal", it was a test OF "hal" - that's not the case. DbLogResourceTest was written to test the DBLogResource, not to test "hal". It happens to use the hal format for the test, but that can easily be changed to json.

DbLogResourceTest should be restored to core D10 and rewritten so it does not depend on the HAL module.

Marking this as "major" because we're supposed to have tests for every feature, and we did have a test for this feature until it was removed.

CommentFileSizeAuthor
#13 raw_diff_9.4_-10.0.txt4.34 KBSpokje

Issue fork drupal-3268078

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TR created an issue. See original summary.

TR’s picture

TR’s picture

TR’s picture

Priority: Major » Critical
Issue tags: +Regression
catch’s picture

Category: Bug report » Task
Issue tags: -Regression

Missing test coverage is a task.

TR’s picture

Someone mistakenly deleting a test that has been part of Drupal core for 5 years is not a bug? And it's not a regression?

If the bar is lower for deleting things than it is for restoring valuable working code, that makes things easy to break but hard to fix. It only took two weeks to delete all that hal module stuff, including at least two tests that should not have been deleted. Now, SIX weeks after I pointed this out, this test is still missing.

Spokje made their first commit to this issue’s fork.

catch’s picture

Status: Active » Needs work

Someone mistakenly deleting a test that has been part of Drupal core for 5 years is not a bug?

no.

Spokje’s picture

Assigned: Unassigned » Spokje

No matter what it is, let's fix/reinstate it :)

Spokje’s picture

Assigned: Spokje » Unassigned
Status: Needs work » Needs review

The MR reintroduces DbLogResourceTest (https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/modules/hal/...) in 10.0.x-dev, this time in the Drupal\Tests\dblog\Functional namespace.

It also reintroduces this core/phpstan-baseline.neon error suppression (https://git.drupalcode.org/project/drupal/-/commit/0cec48668ca71acbe586e81eef6b8b12d1aac2a7?page=10#650015ff26df4f3beec973d0ba4dac1c8a868816_359_359) and adds a new one for DbLogResourceTest::getExpectedUnauthorizedEntityAccessCacheability.

The new addition is inline with the already present ones for FileUploadJsonBasicAuthTest, FileUploadJsonCookieTest and UserRegistrationRestTest.

TR’s picture

+ public function setUp(): void {
This is wrong for Drupal 10. In Drupal 10, this should be protected.

But because ResourceTestBase is one of the only core classes that did not use the correct visibility of setUp() in Drupal 9, if this patch is backported to Drupal 9 then the Drupal 9 version (and ONLY the Drupal 9 version) should use public.

It would be nice to see an interdiff against the deleted DbResourceTest so we can see what changes you made when you restored the deleted test.

Spokje’s picture

FileSize
4.34 KB

Thanks @TR.

+ public function setUp(): void {
This is wrong for Drupal 10. In Drupal 10, this should be protected.

You're absolutely right, didn't correct it after the c/p from D9.
Although I do find it weird it isn't picked up on by neither PHPStorm nor any of our PHPCS/PHPStan tooling.
Anyway: Changed it.

[snip] if this patch is backported to Drupal 9 then the Drupal 9 version (and ONLY the Drupal 9 version) should use public.

I don't think this will be backported to D9, since in there the DbLogResource is still tested here.

It would be nice to see an interdiff against the deleted DbResourceTest so we can see what changes you made when you restored the deleted test.

Attached is a diff between the linked D9.4 DbLogResourceTest and the one in the current MR. Should have done that in the first place.

TR’s picture

Status: Needs review » Reviewed & tested by the community

Looks perfect. Thanks.

  • catch committed f8411d7 on 10.0.x
    Issue #3268078 by Spokje, TR: DBLogResource is no longer being tested
    
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed f8411d7 and pushed to 10.0.x. Thanks!

mondrake’s picture

Confused. Frankly I would not expect to ADD entries to the PHPStan baseline through regular commits. IMHO additions should only be through running the automated baseline generation; patches should REMOVE from the baseline. In the case at hand, both the $entityTypeId static property and the ::getExpectedUnauthorizedEntityAccessCacheability() could be added to the test while maybe something better could be done in the parent and/or the trait that are referencing them without ensuring they exist.

catch’s picture

@mondrake this issue is restoring a test that was mistakenly removed (in the issue that removed HAL module), so we did the absolute minimum to restore the test coverage. If we hadn't mistakenly removed the test in the first place, we also wouldn't have removed those entries from the phpstan baseline either, so the net result is no new phpstan entries. Worth fixing in a follow-up, but not to block restoring the test coverage.

Spokje’s picture

Status: Fixed » Closed (fixed)

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