Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Abstract onboarding plugin code into a PluginsHelper class#3999

Merged
findingsimple merged 13 commits intomasterfrom
refactor/plugin-helper
Mar 27, 2020
Merged

Abstract onboarding plugin code into a PluginsHelper class#3999
findingsimple merged 13 commits intomasterfrom
refactor/plugin-helper

Conversation

@findingsimple
Copy link
Copy Markdown
Contributor

The Onboarding Feature has some existing plugin functionality for retrieving the active and installed plugins that could be useful to other features (e.g. Marketing Dashboard which also allows installation/activation of plugins).

This PR abstracts out the onboarding code into a PluginsHelper class and adds some additional helpers:

  • is_plugin_active()
  • is_plugin_installed()
  • get_plugin_data()
  • get_plugin_path_from_slug()

Detailed test instructions:

I've added some initial tests in b69652a and the existing Onboarding Plugins tests provide some coverage as well.

For manual testing i've put together simple plugin you can use https://gist.github.com/jconroy/daa9751d094dc0a311526f85b5f2c580 to check output of the various functions based on what you are running in your dev environment.

cc @danielbitzer (was most of your work, I'm just spinning it out for review)

Will make it less fragile when Woo plugin data changes
*/
public function test_is_plugin_installed() {

// WooCommerce is installed in the test envrionment.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo here

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.

fixed

$installed = PluginsHelper::is_plugin_installed( 'woocommerce' );
$this->assertEquals( true, $installed, 'WooCommerce should be installed.' );

// Invalud plugin is not.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo here

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.

fixed

// Get facebook plugin path.
$fb_path = PluginsHelper::get_plugin_path_from_slug( 'facebook-for-woocommerce' );

// Activate facebookn plugin.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo here

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.

fixed

@findingsimple findingsimple mentioned this pull request Mar 26, 2020
@octaedro octaedro self-requested a review March 26, 2020 16:55
Copy link
Copy Markdown
Contributor

@octaedro octaedro left a comment

Choose a reason for hiding this comment

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

Hi Jason, you did a great job here. Everything is testing well and the code LGTM :shipit:

@findingsimple findingsimple merged commit c7e4fb3 into master Mar 27, 2020
@findingsimple findingsimple deleted the refactor/plugin-helper branch March 27, 2020 00:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

focus: marketing Related to Marketing Features focus: onboarding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants