Closed (fixed)
Project:
Drupal core
Version:
10.3.x-dev
Component:
ban.module
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
15 Aug 2024 at 23:18 UTC
Updated:
3 Sep 2024 at 13:04 UTC
Jump to comment: Most recent
\Drupal\Tests\ban\Functional\IpAddressBlockingTest inefficiently logs in a user and submits a form several times to test validation that could be done in a unit test. There is some database interaction, so we can split that part to a kernel test.
Before: ~16 seconds
After: ~1 second
BanIpManagerInterface::banIp in a kernel test (BanIpTest::testBanIp)BanAdminTest::testIpValidation)BanIpManagerInterface::banIp in a unit test (BanAdminTest::testFormSubmission)BanAdminTest::testRouteParameter)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
Comment #3
mstrelan commentedComment #4
mstrelan commentedComment #5
smustgrave commentedNice find!
Tweaked the title slightly since it appears the the tests are being improved upon, evident by your comment in the MR too.
From what I can tell no coverage has been lost, as mentioned shaves a few seconds off, and even got to improve the tests it appears.
Comment #10
catchYes this looks great.
Committed/pushed to 11.x and cherry-picked back through to 10.3.x, thanks!
Comment #12
anybodyLooks like
core/modules/ban/tests/src/Unit/BanAdminTest.phpis failing now?------ ----------------------------------------------------------------------
Line core/modules/ban/tests/src/Unit/BanAdminTest.php
------ ----------------------------------------------------------------------
36 Class Drupal\ban\Form\BanAdmin constructor invoked with 1 parameter,
2 required.
74 Class Drupal\ban\Form\BanAdmin constructor invoked with 1 parameter,
2 required.
95 Class Drupal\ban\Form\BanAdmin constructor invoked with 1 parameter,
2 required.
------ ----------------------------------------------------------------------
See #3427545: Allow bulk unbanning / removal and clearing ip addresses (Flush all). Should that be fixed here (reopen) or separate issue?
Comment #13
anybodyUpdate: Sorry, I was wrong, all fine here! The other issue caused the test to fail, a comment was misleading.
All good!