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 #2030537: Translations not downloaded when adding a new language I found a few things in Interface Translation (locale) module's test that could be cleaned-up.
- Not used 'use' statements.
- Definition of modules to be enabled (
public static $modules
) that were already defined by the parent class (LocaleUpdateBase). - A faulty "Contains" comment.
Comment | File | Size | Author |
---|---|---|---|
#8 | interdiff.txt | 726 bytes | benjf |
#7 | 2338011-locale-test-cleanup-7.patch | 3.55 KB | benjf |
locale-test-cleanup.patch | 2.57 KB | Sutharsan | |
Comments
Comment #1
Gábor HojtsyBut locale_test_translate does not depend on locale and/or update?
Comment #2
Sutharsan CreditAttribution: Sutharsan commentedLocaleUpdateInterfaceTest extends LocaleUpdateBase (test base class). LocaleUpdateBase class defines:
public static $modules = array('update', 'update_test', 'locale', 'locale_test');
. The locale_test_translate module does not depend on any module. LocaleUpdateInterfaceTest requires 'locale', 'locale_test' and 'locale_test_translate'. I have looked at a few test classes that extend a base test class. (most) test classes that extend test base classes do not re-define the required modules that are already defined by the base test class. Does that answer your question?Comment #3
Gábor HojtsyBut its the same public static property. How redefining it will not make those base modules removed?
Comment #4
Sutharsan CreditAttribution: Sutharsan commentedDunno, it works (not my most convincing answer ;) ). Perhaps better: a few examples that do the same:
Comment #5
Gábor HojtsyI don't see how that one would work well given that in PHP the extending class overrides the base class' property when doing this. The other two changes look perfect BTW :)
Comment #6
Sutharsan CreditAttribution: Sutharsan commentedIt is because of
$modules
is a static property. This is the issue that made it happen: #1380958: Replace $modules list for WebTestBase::setUp() with ::$modules class properties. WebTestBase cycles through (parent) classes and collects all modules.Comment #7
benjf CreditAttribution: benjf commentedUpdated patch with a few more unused 'use' statements removed. Otherwise, it looks good to me!
Comment #8
benjf CreditAttribution: benjf commentedadding interdiff for the last patch
Comment #9
YesCT CreditAttribution: YesCT commentedI read the whole patch.
Changes all look good.
Inspected locale tests and this gets all the un-used uses there.
We can keep this small and not expand the scope too far. A good small improvement.
Comment #10
alexpottCommitted ab50db3 and pushed to 8.0.x. Thanks!
Comment #12
Gábor HojtsyYay, thanks. Also thanks @Sutharsan for diving in and helping me learn :)