[RFC] Proposal for namespaced class unit tests #16761
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
With all of the class namespacing going on, we don't really have a procedure in place for adding unit tests for new namespaced classes. Luckily this isn't a problem within 3.x right now, but in 4.0 we have added a bunch of classes and right now they have zero test coverage.
With the introduction of Codeception for other test types, we can look at ways to make use of it for addressing this issue. And since Codeception can run PHPUnit tests, there should be no tooling conflicts.
My first draft of this moves the test class for the former
JErrorPage
, nowJoomla\CMS\Exception\ExceptionHandler
, into the Codeception unit test space. The convention I've used thus far is to use a rootcms
directory which would basically be the equivalent of 3.8'slibraries/src/Joomla/CMS
directory then the tests would follow the same structure we have now (the file/folder mapping closely matches up to the production system).I've added arbitrary autoloader support as well using the
Joomla\CMS\Tests
namespace. So in places where we're requiring stub classes, they now have an autoloader mapping.