Problem/Motivation
It has been observed in #3266443 that some tests are not being run due to missing Test suffix to the class names.
Rename such test classes and suffix them with Test.
So far the following such test classes are identified.
ckeditor5/tests/src/FunctionalJavascript/CKEditor5CKEditor4Compatibility.php <- not being run!
jsonapi/tests/src/Functional/RestExportJsonApiUnsupported.php
jsonapi/tests/src/Functional/RestJsonApiUnsupported.php
migrate_drupal/tests/src/Kernel/StateFileExists.php -> handled in #3266443
node/tests/src/Functional/NodeAccessCacheabilityWithNodeGrants.php <- not being run!
Steps to reproduce
Proposed resolution
Rename test classes and suffix them with Test.
Remaining tasks
Raise a MR to Fix rename the tests.
User interface changes
API changes
Data model changes
Release notes snippet
Relevant Draft Change Record :
Issue fork drupal-3268489
Show commands
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 #2
bhanu951 commentedComment #3
longwaveWe should try to add a test that checks for this as well, to prevent it from happening again.
Comment #5
bhanu951 commentedComment #6
lucienchalom commentedI've run the renamed test files and all 4 returned Ok, all pass.
migrate_drupal/tests/src/Kernel/StateFileExists.php
is listed here on the issue as missing the change on the name but is not on the MR. Why is that?
Also I don't have much idea how to create a test to check if all the test files has Test at the end. Suggestions?
I'll leave as Needs works to be open for discussion.
Thank you
Comment #7
bhanu951 commentedComment #11
bhanu951 commentedRebased to 11.x . Still needs a test to check if test ends with
TestComment #14
catchThe ending with test feels like something we could add to phpstan - any non-abstract subclass of whatever the root test base class is. I think we should open a follow-up for that. These specific tests aren't going to be renamed again once this goes in and it'll stop regressions that would cause those tests to fail.
Comment #17
spokjeOpened https://github.com/mglaman/phpstan-drupal/issues/608 and tried to implement it with https://github.com/mglaman/phpstan-drupal/pull/609
As to be expected, that unveiled more incorrectly named test classes.
Also, we need guidance on
*TestBaseclasses, should they always beabstract?For giggles, tried that in a new, separate MR, so to not mess up the one from @Bhanu951.
Seems if we make the offending
*TestBaseclassesabstract, nothing breaks.(The build test failures are from overriding
mglaman/phpstan-drupalwith my PR containing the new rule)Comment #18
catchThe base classes should always be abstract yes, not sure whether it's documented but it's what should happen.
Comment #19
bhanu951 commentedOne more related issue #3268490: Rename and organise Test Traits which we need to work on.
Comment #20
bhanu951 commentedComment #21
bhanu951 commentedWe have a test to check file names here we can utilise it for resolving this issue.
Comment #22
bhanu951 commentedSeems this issue can resolve few more old issues.
Comment #23
spokjeThanks @catch for the confirmation on the "base classes should always be abstract".
@Bhanu951: Not sure if we want to solve all the mentioned issues in one go and or in this one issue.
Let's try the get the proposed rule in PHPStan first and take it from there. Extending it later to deal with class names and Traits seems more manageable.
Postponing this issue on:
- Getting the proposed rule PR into
mglaman/phpstan-drupal- A release of
mglaman/phpstan-drupalwith that rule in it.If that's done we can up the version of
mglaman/phpstan-drupalin the rootcomposer.jsonto that release and fix the found problems both in this issue.Comment #24
catchI'm not sure we should postpone getting 'ghost' tests to run on the phpstan rule, since every day they don't run is an additional chance we could commit something that will make them fail, so would be fine with reversing the order.
Comment #25
spokjeFair point, although it looks like all of the tests are running with our without the "Test" prefix:
From QA run https://dispatcher.drupalci.org/job/drupal8_core_regression_tests/86948/...