[4] Autoloader for psr4 for Unit Testing #36486
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
In developing the first ever Joomla 4 Extension test (#36482) it became apparent that when running Unit Tests, Auto loading of Joomla CMS classes was not working.
For the purposes of #36482 I simply included the classes, but this is unsustainable for the future and autoloader should work.
This PR cleans up the bootstrap process for Unit Tests, and implements a cut down namespace map for Unit Testing (as we cannot use the /administrator/cache/autoload_psr4.php as it doesnt exist at this point, and to create it requires the full working stack and DB, and unit testing is about testing the smallest part of code at a time... to much overhead to use that map, so we have a much smaller one for Unit testing anyway (one class to load at present!)
Testing Instructions
If the unit tests all still work - then this PR works.
Once merged the Unit test in #36482 can be tweaked to remove the
setUpfunction.Actual result BEFORE applying this Pull Request
Unit tests run fine - but autoloading of Joomla CMS namespaces classes fails
Expected result AFTER applying this Pull Request
Unit tests run fine - and autoloading of Joomla CMS namespaces classes works
Documentation Changes Required
None