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.
Comment | File | Size | Author |
---|---|---|---|
#13 | raw_diff_9.4_-10.0.txt | 4.34 KB | Spokje |
Issue fork drupal-3268078
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:
- 3268078-dblogresource-is-no changes, plain diff MR !2133
Comments
Comment #2
TR CreditAttribution: TR commentedComment #3
TR CreditAttribution: TR commentedComment #4
TR CreditAttribution: TR commentedComment #5
catchMissing test coverage is a task.
Comment #6
TR CreditAttribution: TR commentedSomeone 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.
Comment #9
catchno.
Comment #10
SpokjeNo matter what it is, let's fix/reinstate it :)
Comment #11
SpokjeThe MR reintroduces
DbLogResourceTest
(https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/modules/hal/...) in10.0.x-dev
, this time in theDrupal\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 forDbLogResourceTest::getExpectedUnauthorizedEntityAccessCacheability
.The new addition is inline with the already present ones for FileUploadJsonBasicAuthTest, FileUploadJsonCookieTest and UserRegistrationRestTest.
Comment #12
TR CreditAttribution: TR commented+ 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.
Comment #13
SpokjeThanks @TR.
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.
I don't think this will be backported to D9, since in there the DbLogResource is still tested here.
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.Comment #14
TR CreditAttribution: TR commentedLooks perfect. Thanks.
Comment #16
catchCommitted f8411d7 and pushed to 10.0.x. Thanks!
Comment #17
mondrakeConfused. 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.Comment #18
catch@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.
Comment #20
SpokjeFollow-up for the removal of the (re-)added PHPStan error suppression here: #3278052: Fix added core/phpstan-baseline.neon error suppresion for core/modules/dblog/tests/src/Functional/DbLogResourceTest.php