User tests: Successful: Unsuccessful:
Reverts the translate function in the CMSPlugin
class and uses the translate function from the application language object.
Create a GET request task and run it manually in the back end from the web interface.
An output is displayed with the string "Response Code: 200".
An output is displayed with the string "Response Code: 200".
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries Front End Plugins |
Labels |
Added:
?
|
Category | Libraries Front End Plugins | ⇒ | Libraries Front End Plugins Unit Tests |
Why using static function when we have everything from the local application object?
Another reason is, because Text
uses the application from the Factory class and then we can't do correct unit testing. Because code should be autonomic. As soon as the testable class loads it's dependency by it's own, then it violates the inversion of control principle which leads to a dependency chain hell. And no, this is not super theoretic high school stuff, it is a basic principle of software development which we started with the development of Joomla 4.
In this case it would be simple to just set the application on the Factory class but there are places where we have much more complex dependency chains which we want to avoid (this is the reason why so many "unit test" got removed in Joomla 4). When we start to go the way that classes do define their dependencies and not load them by themself, then the code will become simpler, more predictable and easily unit testable. When we start doing excuses, here and there, then it will become messy again over time.
Thank you for the explanation. Please consider a better commit message then please
As the pr will be squashed it uses the pr title. Any suggestion?
It was the title I referred to as that is the commit message.
It is not a revert - that is confusing - perhaps "update"?
Title |
|
Thank you
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-07-03 07:56:58 |
Closed_By | ⇒ | roland-d | |
Labels |
Added:
?
|
Thank you
Why not revert fully to
$this->logTask(Text::sprintf(
?or maybe a better commit message?