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.
Problem/Motivation
We have introduced ParagraphTestBase and only used it on few tests.
Many have repetitive setup and the test base is not used.
Proposed resolution
Use the ParagraphsTestBase.
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff-2780363-15-18.txt | 1.12 KB | ModernMantra |
#18 | use_paragraphstestbase-2780363-18.patch | 20.19 KB | ModernMantra |
#15 | interdiff-2780363-13-15.txt | 1.37 KB | ModernMantra |
#15 | use_paragraphstestbase-2780363-15.patch | 20.54 KB | ModernMantra |
#13 | interdiff-2780363-10-13.txt | 3.45 KB | ModernMantra |
Comments
Comment #2
miro_dietikerLikely candidates for the Para*TestBase
ParagraphsAccessTest
ParagraphsAdministrationTest
ParagraphsPreviewTest
ParagraphsTranslationTest
Comment #3
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedSmall patch that possibly fixes some classes. I had some test fails on local machine that seems is not caused by changes in patch, lets see test bot...
Comment #4
Ginovski CreditAttribution: Ginovski at MD Systems GmbH commented1.Remove all enabled modules in AccessTest that are already enabled in the TestBase ('node', 'paragraphs', 'field', 'field_ui', 'block').
Same for AdministrationTest, PreviewTest and TranslationTest.
2. Correct the setup function in all the extending classes (remove $this->drupalPlaceBlock() when it is repeating with the TestBase)
3. Use function loginAsAdmin from the TestBase when possible in the extending classes (instead of $this->drupalLogin()).
Comment #5
miro_dietikerJust switching to the Paragraphs base is not of value. It only makes sense to switch to it, if the test itself gets more simple. Using a base introduces general setup and helpers. Each of the use cases need to switch leveraging them.
Comment #6
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedConsidering previous two comments #4 and #5, providing new patch. No interdiff since previous trials have not been correct.
Comment #8
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedReverted some stuff for ParagraphsUninstall (seems that we did not need to use there ParagraphsTestBase) and some small fixes for failures of tests. I hope it will be green.
Comment #9
johnchqueI think this can be all removed. since we are calling the parent anyway.
Let's try to use the methods provided by base so the tests are shorter. :)
Comment #10
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedSome more refactoring... This refactoring and adopting classes to use
ParagraphsTestBase
broke many tests and thus going too much into refactoring will cause almost 'reimplementation' of some tests (for instanceParagraphsAdministrationTest
)Comment #12
miro_dietikerIMHO you should apply the transformation step by step by trying to avoid to create bigger breaks as you started at #3
So yeah, that's the purpose of using the base - tranforming lots of duplicated code into the methods / helpers provided. But that is more refactoring than reimplementation.
Comment #13
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedA little bit more refactoring in ParagraphsAdministrationTest.
Comment #15
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedTests should be green now :)
Comment #16
miro_dietikerWhat should happen with this commented code?
Comment #17
johnchqueI think we can use addParagraphedContentType instead if this code.
Comment #18
ModernMantra CreditAttribution: ModernMantra at MD Systems GmbH for MD Systems GmbH commentedReferring to comment 17, it is already done, otherwise it would be everything 'red'. Removed some commented block of code and improved comment. Should be ok now :)
Comment #20
miro_dietikerYay, committed. :-)