? Success

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
14 Dec 2014

Summary

To get around some B/C issues with using Composer's autoloader, we created a fork of the full Composer\Autoload\ClassLoader class and modified its loadClass() method to hook into Joomla's own autoloader.

Issues

1) A complete fork of the class is not necessary for the single method call. We should be able to safely extend Composer's ClassLoader and just override the method we need to. From my testing, this is possible and works without issue.

2) If you have packages installed via a Composer global installation, for example composer global require phpunit/phpunit (to install PHPUnit globally instead of a per-project dependency), executing those global scripts on the Joomla installation fails due to a redeclared class (ClassLoader) and function (includeFile). Now that our loader is extending ClassLoader, we can make our class wise and only import the class/file included with Joomla if another script has already imported ClassLoader.

Testing Instructions

Within the CMS, testing is simple - Apply the patch :smile:

If you have packages Composer packages globally installed and are executing those on a Joomla installation, pre-patch you should get a failure due to the redeclared class/function. Post-patch, scripts should function properly.

avatar mbabker mbabker - open - 14 Dec 2014
avatar jissues-bot jissues-bot - change - 14 Dec 2014
Labels Added: ?
avatar nikosdion
nikosdion - comment - 14 Dec 2014

@test Success.

Confirmed the issue with PHPUnit installed through Composer and confirmed that the patch fixes it. Also confirmed that Joomla! works fine -itself and some extensions I regularly use- before and after the fix.

Note to future testers: You can install PHPUnit through Composer using the instructions in https://phpunit.de/manual/current/en/installation.html#installation.composer Please remember to add the ~/.composer/vendor/bin/ directory in your path, as the first directory. It got me the first time I tried testing this patch. Whoops!

avatar chrisdavenport
chrisdavenport - comment - 14 Dec 2014

@test Success.

Finally, I've got the unit tests to run! I was racking my brains trying to get the tests to work last week and eventually just gave up. Now I know it wasn't me!

I also had to add

"phpunit/dbunit": ">=1.2"

into the "require-dev" in composer.json otherwise it falls over as soon as it gets to the database tests.

avatar chrisdavenport chrisdavenport - test_item - 14 Dec 2014 - Tested successfully
avatar wilsonge wilsonge - close - 15 Dec 2014
avatar wilsonge wilsonge - change - 15 Dec 2014
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2014-12-15 03:07:05
avatar wilsonge
wilsonge - comment - 15 Dec 2014

Merged with 2 good tests. Thanks Michael!

Add a Comment

Login with GitHub to post a comment