Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GravityForms connector test implemented #1139

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

kidunot89
Copy link
Contributor

@kidunot89 kidunot89 commented Jul 10, 2020

Partially fixes #1093

Summary checklist

  • gform_after_save_form callback test implemented and passing.
  • gform_delete_lead callback test implemented and passing.
  • gform_pre_confirmation_save callback test implemented and passing.
  • gform_pre_notification_save callback test implemented and passing.
  • gform_pre_notification_deleted callback test implemented and passing.
  • gform_pre_confirmation_deleted callback test implemented and passing.
  • gform_confirmation_status callback test implemented and passing.
  • gform_notification_status callback test implemented and passing.
  • check function test implemented and passing.
  • gform_post_note_added callback test implemented and passing.
  • gform_pre_note_deleted callback test implemented and passing.
  • gform_update_status callback test implemented and passing.
  • gform_update_is_read callback test implemented and passing.
  • gform_update_is_starred callback test implemented and passing.
  • log_form_action function test implemented and passing.
  • gform_post_export_entries callback test implemented and passing.
  • gform_forms_post_import callback test implemented and passing.
  • gform_export_separator callback refactored. It's now the gform_export_form callback and has been tested.
  • No test was written for thegform_export_options callback. Further inspection is needed to determine it's relevance.

@kidunot89 kidunot89 added the work in progress Issue or pull request is still under development (DO NOT MERGE) label Jul 10, 2020
@kidunot89 kidunot89 self-assigned this Jul 10, 2020
@kidunot89 kidunot89 changed the title Tests/gravityforms connector GravityForm connector test implemented Jul 10, 2020
@kidunot89 kidunot89 changed the title GravityForm connector test implemented GravityForms connector test implemented Jul 10, 2020
@kidunot89 kidunot89 removed the work in progress Issue or pull request is still under development (DO NOT MERGE) label Jul 16, 2020
@kidunot89 kidunot89 requested a review from kopepasah July 24, 2020 17:18
tests/bootstrap.php Outdated Show resolved Hide resolved

// Do stuff.
$notification = array(
'id' => uniqid(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Align assignments.

composer.json Outdated
@@ -15,7 +15,8 @@
"wp-cli/wp-cli-bundle": "^2.2",
"wp-coding-standards/wpcs": "^2.2",
"wp-phpunit/wp-phpunit": "^5.4",
"wpsh/local": "^0.2.3"
"wpsh/local": "^0.2.3",
"wp-premium/gravityforms": "^2.4.17"
Copy link
Contributor

Choose a reason for hiding this comment

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

@kidunot89 we need to find another way to pull in this plugin and test. While GPL code on in wp-premium Org is technically legal (I'm not a lawyer 🤐), we will not support it as it takes away from the developers who built these plugins and poses as a potential security risk.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can pull it in as a zip someway? I have a developer's license, so access is not a problem.

Copy link
Contributor Author

@kidunot89 kidunot89 Jul 30, 2020

Choose a reason for hiding this comment

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

I'm open to ideas, is there a recommend method you have for pull this plugin in?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am also open to ideas. One that comes to mind is we have a private S3bucket (or other storage service) from which we can read with private keys in Github. The we can use an archive installer with Composer to pull in those packages.

I checked, but did not find any way to add files to Github or Travis for pulling in the data, but the above solution may be a good start.

@kasparsd any ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, I'm not sure how to handle this. How about we skip the tests if the dependency is not found for now?

Copy link
Contributor

@kasparsd kasparsd left a comment

Choose a reason for hiding this comment

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

@kidunot89 The tests alone look great. Could we get those merged in now and leave the plugin dependency out of tracking/dependency list until we find a solid solution for working with commercial plugins that don't have source code available publicly.

@kidunot89
Copy link
Contributor Author

@kasparsd I'm not sure about leaving the plugin out, since the tests relies on it.

@derekherman
Copy link

@kidunot89 and @kasparsd In order to add the plugin it would need to be done in a way that is progressive and legal. It should not fail a build if the plugin is missing, so tests should only run if installed and active, and while we can install it with Composer I'm not sure if we can gracefully fail.

At any rate the minimum changes are that we need to add this object to the repositories array.

{
  "type": "package",
  "package": {
    "name": "gravityforms/gravityforms",
    "version": "2.4.21.3",
    "type": "wordpress-plugin",
    "dist": {
      "type": "zip",
      "url": "https://www.gravityhelp.com/wp-content/plugins/gravitymanager/api.php?op=get_plugin&slug=gravityforms&key={%GRAVITYFORMS_KEY}"
    },
    "require": {
      "composer/installers": "^1.4",
      "gotoandplay/gravityforms-composer-installer": "^2.3"
    }
  }
}

Also, we will need to add "gravityforms/gravityforms": "2.4.21.3" to require-dev and find a way to fail gracefully if the environment variable for the key it either missing or invalid. Locally you would also need to create a .env file and add GRAVITYFORMS_KEY=YOUR_SECRET_KEY and for the build to pass we can add the elite key we use for XWP projects to Travis CI.

There are really only two hurdles:

  1. Make tests run with/without plugin
  2. Degrade gracefully in Composer

@kidunot89 kidunot89 requested review from kasparsd and removed request for kopepasah November 25, 2020 17:25
@kidunot89
Copy link
Contributor Author

kidunot89 commented Nov 25, 2020

@kasparsd @ivankruchkoff The GravityForms package has been updated as @derekherman suggested, and I've added the GRAVITYFORMS_KEY as a secret in Travis-CI. If either of your reviews approve this should finally be all ready for merging.

@kidunot89 kidunot89 added this to the 3.7.0 milestone Jan 4, 2021
@kidunot89 kidunot89 mentioned this pull request Feb 22, 2021
7 tasks
Copy link
Contributor

@kasparsd kasparsd left a comment

Choose a reason for hiding this comment

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

@kidunot89 I tried looking into the Travis issue but I'm not sure what is happening. Could it be that some of the dependencies were updated via composer update? It appears to be happening here:

https://github.com/symfony/polyfill-php80/blob/dc3063ba22c2a1fd2f45ed856374d79114998f91/bootstrap.php#L23

composer.json Outdated
"type": "wordpress-plugin",
"dist": {
"type": "zip",
"url": "https://www.gravityhelp.com/wp-content/plugins/gravitymanager/api.php?op=get_plugin&slug=gravityforms&key={%GRAVITYFORMS_KEY}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Does that mean that only people with GF key will be able to work on the plugin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kasparsd Yea, it is. 🤔 This might need some further tooling.

Copy link
Contributor Author

@kidunot89 kidunot89 Feb 25, 2021

Choose a reason for hiding this comment

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

I think we should skip GravityForms connector test unless the developer installs it as a dev specifically with composer. Then can probably move the whole GravityForms install process into the Travis-CI script and take it out of the composer.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kasparsd ☝️ What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is a good idea! We could even have another composer.json file for installing these external dependencies.

@kidunot89 kidunot89 force-pushed the tests/gravityforms-connector branch from 7af0429 to 01a914d Compare March 2, 2021 01:17
@kidunot89 kidunot89 force-pushed the tests/gravityforms-connector branch from 01a914d to 595d5ae Compare March 2, 2021 01:32
Comment on lines +75 to +93
- |
composer config repositories."1" "{
\"type\": \"package\",
\"package\": {
\"name\": \"gravityforms/gravityforms\",
\"version\": \"2.4.21.3\",
\"type\": \"wordpress-plugin\",
\"dist\": {
\"type\": \"zip\",
\"url\": \"https://www.gravityhelp.com/wp-content/plugins/gravitymanager/api.php?op=get_plugin&slug=gravityforms&key=$GRAVITYFORMS_KEY\"
},
\"require\": {
\"composer/installers\": \"^1.4\",
\"gotoandplay/gravityforms-composer-installer\": \"^2.3\"
}
}
}"
- npm install
- composer require --dev gravityforms/gravityforms:2.4.21.3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kasparsd This should do the trick. I don't think there is a need for an alternative composer.json, but it does make the repositories array and object.
image
But I revert it in the before_deploy 🤔.

@@ -50,6 +50,7 @@ jobs:
if: branch IS present AND type = push
script: npm run release
before_deploy:
- git restore composer.json
Copy link
Contributor Author

@kidunot89 kidunot89 Mar 2, 2021

Choose a reason for hiding this comment

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

@kasparsd This is to revert the changes made in the install.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Test Coverage
4 participants