Skip to content

Fix file attribute in ListTestsAsXml for abstract class inheritance #6278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

joteejotee
Copy link

The file attribute of <testCaseClass> nodes in --list-tests-xml output was incorrect when test methods were inherited from abstract base classes. The file path pointed to the abstract class file instead of the concrete test class file.

This fix uses ReflectionClass to get the actual class file path instead of the method file path.

Fixes #6097

@joteejotee joteejotee force-pushed the fix/6097-testclass-file-attribute branch from 0e70ea0 to a5875eb Compare July 18, 2025 09:58
@joteejotee
Copy link
Author

💡 Note: Although GitHub UI shows a merge conflict, the branch is already rebased onto upstream/10.5 and contains only a single clean commit.
There are no actual conflicts, and the changes can be safely merged.

Please let me know if any adjustments are needed!

@@ -12,11 +12,11 @@ require_once __DIR__ . '/../../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.
%APHPUnit %s by Sebastian Bergmann and contributors.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong.


(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
%APHPUnit %s by Sebastian Bergmann and contributors.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong.

@sebastianbergmann
Copy link
Owner

"branch is already rebased onto upstream/10.5" conflicts with the target of this PR being main.

@joteejotee
Copy link
Author

Thanks for the quick review!
I'll fix the test files as you pointed out and also update the target branch of this PR to 10.5 to avoid the merge conflict warning.
I'll push the updates shortly.

@joteejotee joteejotee force-pushed the fix/6097-testclass-file-attribute branch from a5875eb to bc5dffe Compare July 19, 2025 07:25
@joteejotee joteejotee changed the base branch from main to 10.5 July 19, 2025 07:59
Use ReflectionClass to get actual class file path instead of method file path.

Fixes sebastianbergmann#6097
@joteejotee joteejotee force-pushed the fix/6097-testclass-file-attribute branch from bc5dffe to e16dc8c Compare July 22, 2025 10:51
@joteejotee
Copy link
Author

Sorry about that — I forgot to include the changelog entry initially. I've now added it to ChangeLog-10.5.md following the project format.

@sebastianbergmann
Copy link
Owner

Sorry about that — I forgot to include the changelog entry initially. I've now added it to ChangeLog-10.5.md following the project format.

For future reference: please don't, I take care of the ChangeLog after merging a pull request.

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Jul 30, 2025

PHPUnit 10.5 does not generate a file attribute in the document generated using --list-tests-xml so there is nothing to fix. However, this pull request introduces said file attribute. Futhermore, PHPUnit 10.5 no longer receives bug fixes.

I have now merged @mondrake's tests from #6101 into 11.5 and applied your fix from this pull request to 11.5 to address #6097. From there, the changes were merged to 12.2 and main.

Thank you, @mondrake and @joteejotee, for working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The file attribute of <testClass> node of XML test list can be wrong
2 participants