User tests: Successful: Unsuccessful:
Pull Request for Issue # .
This PR makes several improvements to controller classes as explained below:
Add $option property to Controller class. We will now get $option from $config or input, not guessing it from class name like in none-namespace class anymore
Correct behavior or getName() method:
Implement getModel method for admin controller. With this method, we can delete most of blank getModel method in admin controllers (I deleted some in this PR for demo purpose)
Some code clean up, docblock, codestyle for easy navigating between method/class in modern IDE like PHPStorm
Pass $option and $name property to Model and View creation code so that the Model and View class won't have to guess these important properties from class name anymore
getName() method of Controller return name of actual controller (not always return name of component like before)
Note the getModel method of Admin controller implemented.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_banners com_categories com_content Libraries |
Labels |
Added:
?
|
Category | Administration com_banners com_categories com_content Libraries | ⇒ | Administration com_banners com_categories com_content Libraries Unit Tests |
Labels |
Added:
?
|
I have tested this item
I have navigated through several list and edit views on the backend in com_users (users, notes, fields), com_menus (menus, menu items), com_banners(banners, categories, clients, tracks), com_content (articles, categories, fields, field groups, featured articles), published and unpublished several banners and several articles and have found no problems whatsoever. Also went through several pages and modules on the frontend and everything seems to be fine.
Joomla! 4.0.0-dev
OS: Linux Deepin 15.3
Kernel: 4.4.0-3-deepin-amd64
Google Chrome: 56.0.2924.76 (64 bit)
PHP: 7.0.12-2
MySQLi 5.7.15-1
Category | Administration com_banners com_categories com_content Libraries Unit Tests | ⇒ | Administration com_content Libraries Unit Tests |
Milestone |
Added: |
Milestone |
Added: |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-09-29 13:25:30 |
Closed_By | ⇒ | joomdonation |
Travis still false here, but it comes from JPaginationTest and not related to this PR. I did, however, had to change some tests in JControllerFormTest. Those tests are written for none namespace classes and might not be correct anymore now:
As mentioned in PR description, we are now getting option directly from config or input, not guessing from class name anymore. So for those tests, I added option to config array of controller constructor
For controller class name MincesControllerMince, in a Joomla component, I assume it is a sub-controller and comes from the request has task=mince.task_name. With the code I implemented in getInstance() method https://github.com/joomdonation/joomla-cms/blob/721dcc9d14265b8a2a1591f4753503912637223d/libraries/src/CMS/Controller/Controller.php#L296 , we will have name=mince passed to $config array. That's why I pass name=mince to the controller constructor of the test