Closed (outdated)
Project:
Drupal core
Version:
11.x-dev
Component:
simpletest.module
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
2 May 2013 at 18:34 UTC
Updated:
20 Aug 2025 at 16:34 UTC
Jump to comment: Most recent
Comments
Comment #1
yesct commentedBased on irc conversation between @tim.plunkett and @jhodgdon
can we add a test to Drupal 8.x that checks whether all class-containing files are named correctly (class name + .php)?
The problem that tests were refactored and neither the test name nor the file name was changed.
We could theoretically parse each class name, and check which class it extends, but it could possibly have to go up several levels...
UnitTestBase, WebTestBase, and DrupalUnitTestBase all extend TestBase anyway.
reflection stuff in PHP might be relevant.
In java you could do something like $foo is 'className'
foreach ($classname) {
$foo = new $className
well you don't need an instance to do it
if !foo is whatever_it should_be
is_subclass_of
If it's important that the class names are correct, then make a test that enforces it. :)
then this test will fail if anyone refactors without renaming.
Comment #2
jhodgdonThe idea here is to use
http://php.net/manual/en/function.is-subclass-of.php
So you can do for instance
is_subclass_of('TestClass1Name', 'DrupalUnitTestBase'))
vs. checking that 'TestClass1Name' ends in 'UnitTest'
And the test pseudocode would be:
a) Find all classes that subclass TestBase.
b) Verify that all classes in (a) that are subclasses of UnitTestBase have names ending in UnitTest.
c) Verify that all classes in (a) that are subclasses of DrupalWebTestBase do not have Unit in their names.
right?
Comment #3
xjmHm, this test would have enormous overhead to enforce a naming convention only for tests. I think this is not worthwhile except in eventual coding standards automated testing. I would suggest postponing it on that meta (which is also postponed to 8.1.x at this point).
Comment #4
xjmPostponing on coding standards checking, #1518116: [meta] Make Core pass Coder Review, and 8.1.x.
Comment #20
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #21
smustgrave commentedBased on #3 going to close this one out. Think we've been pretty good about this.