Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Mar 2019 at 15:06 UTC
Updated:
24 Jan 2025 at 13:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirAdded that and as a test, removed most resetCache() calls in node.module tests. Did run one locally and it still passed.
Comment #4
hchonov+1 on the solution, we actually even use it.
I haven't thought on proposing this to core, because it does not cover the case, where the static cache service is exchanged in the storage. It might be better to provide a new method on the entity storage -
resetStaticCache()and iterate over the entity storages and call the method on each of them.However I am also fine with the current approach, because the probability for the case I've mentioned is very little :).
Comment #7
berdirReroll and fixing the failing test. That assert is the wrong way round, assertGreaterThan() is pretty confusing as it tests that the second argument is larger than the first, so it's kind of reversed than what you'd think. That's also consistent with the previous assert above, which is also "reversed". This was copied and not updated because it passed due to the static cache.
Comment #9
raman.b commentedRequired another re-roll after 3159230.
Also, the failed test from #7 is passing locally, so moving back to Needs review
Comment #14
ranjith_kumar_k_u commentedRerolled #9
Comment #19
berdirBeside removing a lot of complexity (when and when not to reset cache) and lines of code, it also uncovers bugs and incorrect assumptions in tests when we forget to reset the cache.
For example https://git.drupalcode.org/project/drupal/-/merge_requests/10075/diffs?c.... That test never actually tested what I thought it did, because it was always testing against the original stale entity.
Comment #21
smustgrave commented1) Drupal\Tests\block\Functional\BlockCacheTest::testCachePermissions
Behat\Mink\Exception\ResponseTextException: The text "smx906fw" was not
found anywhere in the text of the current page.
Appears to be random but since 100+ commits back now I did a simple rebase to make sure.
I wasn't 100% sure if we should have a CR but since it's just around tests I didn't think it would be needed.
Edit
Rebase was good and green.
Change LGTM
Comment #22
bradjones1I'm not sure if there is a policy that speaks to this but a CR would be good as this is a pretty important change to the base test setup and is not obvious.
Comment #23
smustgrave commentedLets do it!
Comment #24
berdirCreated https://www.drupal.org/node/3491185.
This is mostly a DX thing when writing new tests and shouldn't affect any existing tests, except those that implicitly or explicitly rely on the current static cache behavior, like the one example in core that I had to fix.
For new tests, it should now mostly just work without having to think about internal entity features.
Note: I have not verified if every single resetCache() call in core is still needed, but I removed enough to show that this works I think and quite a few are still necessary as their changes are not done by form submissions.
Comment #25
smustgrave commentedCR reads well too me. So restoring previous status.
Comment #26
berdirRebased and removed an unused variable that is now reported on by phpcs, no other changes.
Comment #29
catchLooks great! Committed/pushed to 11.x, thanks!
Comment #30
wim leers🤩
Developers around the globe thank you!