Opened 18 years ago
Closed 18 years ago
#5210 closed enhancement (fixed)
Refactor plugin (de)activation code for unit testing
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description ¶
To perform unit tests involving plugin (de)activation, it is currently necessary to either duplicate or indirectly call the logic in wp-admin/plugins.php. The code additionally duplicates itself (there is separate logic for deactivating one and deactivating all plugins). The attached patch moves the activating, deactivating, and deactivating all out into separate functions, which should allow for easier testing.
It may or may not be appropriate to break out the plugin inclusion code in wp-settings.php into its own function. The inclusion action is performed by the original wp-admin/plugins.php code, as well as the refactored code, so it's not strictly necessary with the current setup for the plugin activation code to be called once the plugin has been activated. This patch makes the smaller change, and does not break out the wp-settings.php code.
Pull Requests
- Loading…
Change History (7)
@
18 years ago
Moves the plugin (de)activation logic from wp-admin/plugins.php to wp-admins/includes/plugin.php
#2
@
18 years ago
Done. I don't know what the convention is for "error codes"; I just made two up, so someone should probably check that.
#3
@
18 years ago
I'm not sure what WordPress's stance on this is.. So someone please correct me if i'm wrong.
rather than setting a variable and returning it at the end, You should be simply returning the WP_Error object at that point in time.
With the current code, it'll create a retval with an error.. but it'll then continue to work on and follow the rest of the code regardless, Whereas before, it simply dies off at that point rather than completing.
@
18 years ago
Moves the plugin (de)activation logic from wp-admin/plugins.php to wp-admins/includes/plugin.php
Instead if issuing wp_die() from the functions, return WP_Error and let the caller die. Other than that, looks good.