User tests: Successful: Unsuccessful:
This first PR introduces a wrapper class for the JUserHelper class to get rid of the static methods to improve the testing basis of the code for our PHPUnit tests!
It should be used as a template for other classes (JPluginHelper etc.) which also have to be considered.
The static methods (and the wrappers) will be removed completely in Joomla! 4.x.
Labels |
Added:
?
|
Category | ⇒ | Libraries Unit Tests |
@wilsonge Please read this: https://github.com/sebastianbergmann/de-legacy-fy#wrapping-a-static-api-class
We need this wrapper in Joomla! 3.x for backward compatibility, it will be removed in Joomla! 4.x.
In practice, Joomla has always used static helpers. In theory, it isn't necessarily the best way to go about things.
Travis failed because we need also to adjust the loader to handle the new introduced "helperwrapper" classes.
loader.php - change in the function import
// Handle special case for helper classes.
if ($class == 'helper' || $class == 'helperwrapper')
If you create a new folder named helper
in the libraries/joomla/user
folder then rename the file to wrapper.php
it'll work. The autoloader expects a new folder at each capital letter with the final one being the file name reference.
Labels |
Added:
?
|
Moving to RTC
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/4717.
Status | Pending | ⇒ | Ready to Commit |
@sebastianbergmann Can you please take a look on our implementation? Thanks!
Looks good to me, @Kubik-Rubik.
Thanks @sebastianbergmann!
Merged to 3.4-dev
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2014-10-17 09:36:20 |
Labels |
Removed:
?
|
What's the benefit of having an external wrapper class for this? I mean I get unit testing benefits but generally the principle of helper classes is that they should be static methods. If they aren't going to be statics then imo they should just be more methods in JUser. I really don't see the use of them being this standalone class you have to inject into JUser