Skip to content

Create AJAX_Runner#79

Merged
jjgrainger merged 4 commits into
trunkfrom
feature/create-ajax-runner-class
Feb 16, 2023
Merged

Create AJAX_Runner#79
jjgrainger merged 4 commits into
trunkfrom
feature/create-ajax-runner-class

Conversation

@jjgrainger
Copy link
Copy Markdown
Contributor

Adds the AJAX_Runner class.

Closes #15

@jjgrainger jjgrainger added [Type] Enhancement A suggestion for improvement of an existing feature Infrastructure Issues for the overall plugin infrastructure Milestone 1 labels Feb 14, 2023
Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjgrainger Overall this looks solid, left a few small points of feedback.

Comment thread includes/Checker/AJAX_Runner.php Outdated
Comment thread includes/Checker/AJAX_Runner.php Outdated
Comment thread tests/Checker/AJAX_Runner_Tests.php Outdated
Comment thread tests/Checker/AJAX_Runner_Tests.php
Comment thread includes/Checker/AJAX_Runner.php Outdated
Comment thread includes/Checker/AJAX_Runner.php Outdated
Comment thread includes/Checker/AJAX_Runner.php Outdated
Comment thread includes/Checker/AJAX_Runner.php Outdated
Comment thread includes/Checker/AJAX_Runner.php Outdated
@jjgrainger
Copy link
Copy Markdown
Contributor Author

Thanks @felixarntz I've made the updates based on your feedback.

Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjgrainger Basically LGTM, just a few nit-picks. I can address them really quickly to unblock.

Comment thread includes/Checker/AJAX_Runner.php Outdated
Comment thread includes/Checker/CLI_Runner.php Outdated
Comment thread includes/Checker/AJAX_Runner.php
Copy link
Copy Markdown
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jjgrainger!

@felixarntz
Copy link
Copy Markdown
Member

@joemcgill Can you give this a quick sanity check and 2nd approval (just to unblock because Mukesh is traveling this week)?

Copy link
Copy Markdown
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions, but this all looks good to me.

// Get the plugin name from the AJAX request.
$plugin_file = Plugin_Request_Utility::get_plugin_basename_from_input( $_REQUEST['plugin'] );

$this->checks = new Checks( WP_PLUGIN_DIR . '/' . $plugin_file );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the plugin is always being loaded from inside the plugins directory rather than as an mu-plugin or required via code, as is often the case during unit testing setups, or some platform configurations. Is that an intentional limitation at this point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joemcgill thats a great point and something we should probably look into in the future. For this initial milestone I believe the intention is to only check plugins found within the main plugin directory.

use WordPress\Plugin_Check\Checker\AJAX_Runner;
use WordPress\Plugin_Check\Checker\Check_Result;

class AJAX_Runner_Tests extends WP_UnitTestCase {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an observation, but since all of these are filtering the wp_doing_ajax value, is there any value in moving this shared code to a fixture that runs before each test? I also wonder if there's any value in having a test case that confirms the expected behavior if wp_doing_ajax is false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @joemcgill I've added an additional test to check behaviour when wp_doing_ajax is false. We can potentially refactor the tests here in future to reduce duplicate code here.

@jjgrainger jjgrainger merged commit 1b06684 into trunk Feb 16, 2023
@jjgrainger jjgrainger deleted the feature/create-ajax-runner-class branch February 16, 2023 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Infrastructure Issues for the overall plugin infrastructure [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create AJAX_Runner class

3 participants