User tests: Successful: Unsuccessful:
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.
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
.
Within the CMS, testing is simple - Apply the patch
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.
Labels |
Added:
?
|
@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.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-12-15 03:07:05 |
Merged with 2 good tests. Thanks Michael!
@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!