Repository navigation
Tests: Add unit test coverage for the row classes and checkbox in WP_Plugins_List_Table::single_row() - #14606
Conversation
…Plugins_List_Table::single_row().
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
The assertions match the source, and CI passes. One note about fixture cleanup inline.
| private function render( $plugin_data = array(), $headers = '' ) { | ||
| // is_network_only_plugin() reads the plugin headers on multisite. | ||
| $dir = WP_PLUGIN_DIR . '/' . $this->slug; | ||
| $this->assertTrue( mkdir( $dir ), 'The test plugin directory should be created.' ); |
There was a problem hiding this comment.
In core tests, WP_PLUGIN_DIR is tests/phpunit/data/plugins, which is a tracked directory. If a run stops partway, such as on a fatal error or Ctrl+C, tear_down() never runs and this fixture folder stays there. The slug comes from a counter that starts at 1 again on the next run, so mkdir() fails on the same folder name. So every test in the class fails here until someone deletes the folder by hand. The leftover also shows up in git status.
Could this helper, or set_up(), remove a leftover folder first? #14600 already does this: its remove_plugin() helper runs in both set_up() and tear_down().
There was a problem hiding this comment.
Good catch, thanks! Added a remove_plugin() helper that clears a leftover folder before mkdir() and in tear_down(), in d8f2c3c. I checked it with a leftover folder in place: the old code failed and the new code passes.
…gins_List_Table row checkbox tests.
Description
Adds tests for the row classes and the bulk action checkbox that
WP_Plugins_List_Table::single_row()outputs for each plugin. These had no tests; #14598, #14602 and #14603 cover the action links and row meta of the same method.The tests render a row for a temporary plugin, read the opening
trtag and the checkbox column from the output, and set the dependency state through the static properties ofWP_Plugin_Dependencies, which the shared plugin dependencies test case resets. They cover:inactiveandactiverow classes, and the full checkbox markup;updateclass when the plugin's PHP requirement is not met, and a checkbox with theupdateclass when its WordPress requirement is not met;updateclass only when the plugin has an update and the upgrade view has updates;pausedandis-uninstallableclasses;Removing or changing each branch of the row classes and checkbox makes at least one test fail on single site or multisite.
This is a test-only change; no production code is modified.
Testing Instructions
npm run test:php -- --filter Tests_Admin_wpPluginsListTableRowCheckboxnpm run test:php -- --filter Tests_Admin_wpPluginsListTableRowCheckbox -c tests/phpunit/multisite.xmlnpm run test:php -- --filter Tests_Admin_wpPluginsListTableRowCheckbox --order-by=randomnpm run test:php -- --group pluginsnode ./tools/local-env/scripts/docker.js run --rm php ./vendor/bin/phpcs tests/phpunit/tests/admin/wpPluginsListTableRowCheckbox.phpTrac ticket: https://core.trac.wordpress.org/ticket/65819
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Brainstorming edge-case scenarios and drafting test boilerplate; test architecture, assertions, and local PHPUnit verification were written and validated by me.