Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While working on another issue, I've found there's a lot of tests that create a flag using the form. This seems excessive to me. Admittedly, each link type plugin needs to work with the flag form to check its own stuff is there, but aside from that, the flag form only needs to be tested once. The rest of the time, flags should be getting created/edited programmatically so tests run quicker.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2558503.2.refactorTests.patch | 5.69 KB | socketwench |
Comments
Comment #2
socketwench CreditAttribution: socketwench as a volunteer commentedFrom my poking around, there's only three places where this issue would apply:FlagFieldEntryTestFlagServiceTestFlagEnableDisableTestThere are larger refactoring problems elsewhere. FlagServiceTest creates the flag programmatically without using FlagTestBase::createFlag(). FlagConfirmFormTest, FlagFieldEntryTest, and FlagSimpleTest call drupal_post_form() directly instead of using FlagTestBase::createFlagWithForm(). Many of these classes don't take advantage of FlagTestBase now that it's in the repo. These will need new issues.
Comment #3
socketwench CreditAttribution: socketwench as a volunteer commentedDid a few refactors, by no means finished.
Comment #4
joachim CreditAttribution: joachim commented> There are larger refactoring problems elsewhere
Agreed! After filing this, I had another think and figured we need a meta-task to think about the complete picture of the tests we have, but life intervened and I've not filed it yet.
Comment #5
joachim CreditAttribution: joachim commentedWe shouldn't be creating the flag with the form at all here -- the test isn't about the Flag admin UI, so we should create the flag programatically.
Comment #6
socketwench CreditAttribution: socketwench as a volunteer commentedThen when where do we test the Confirm Form link type form?
Comment #7
joachim CreditAttribution: joachim commentedAh right, yes, sorry. I see what you mean -- we need to test the admin form elements for the link type we're testing.
I'd prefer it if the patch were split up -- with tests I feel it's very easy to remove too much and then never notice it's gone because tests pass. Also, the time I have to review these days is usually too early in the morning or too late at night :/ so simpler patches are preferable for reasons of limited brain power too!
Comment #8
socketwench CreditAttribution: socketwench as a volunteer commented