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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.env
.idea
.env
.DS_Store
/node_modules/
/vendor/
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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.

- openssl aes-256-cbc -K $encrypted_49634e5b1863_key -iv $encrypted_49634e5b1863_iv -in ./local/travis/travis_deploy_key.enc -out ~/.ssh/id_rsa -d
- chmod 600 ~/.ssh/id_rsa
deploy:
@@ -71,7 +72,25 @@ before_install:
- composer self-update --1

install:
- |
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
Comment on lines +75 to +93
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 🤔.


script:
- npm run lint
7 changes: 2 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
"url":"https://wpackagist.org"
}
],
"require": {
@@ -29,10 +29,7 @@
},
"config": {
"process-timeout": 600,
"sort-packages": true,
"platform": {
"php": "5.6.20"
}
"sort-packages": true
},
"extra": {
"wordpress-install-dir": "local/public",
1,445 changes: 1,042 additions & 403 deletions composer.lock

Large diffs are not rendered by default.

127 changes: 45 additions & 82 deletions connectors/class-connector-gravityforms.php
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ class Connector_GravityForms extends Connector {
'gform_post_form_views_deleted',
'gform_post_export_entries',
'gform_forms_post_import',
'gform_export_form',
'gform_delete_lead',
'gform_post_note_added',
'gform_pre_note_deleted',
@@ -225,16 +226,11 @@ public function callback_gform_after_save_form( $form, $is_new ) {
$id = $form['id'];

$this->log(
sprintf(
/* translators: %1$s a form title, %2$s a status (e.g. "Contact Form", "created") */
__( '"%1$s" form %2$s', 'stream' ),
$title,
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' )
),
/* translators: %1$s a form title, %2$s an action (e.g. "Contact Form", "created") */
__( '"%1$s" form %2$s', 'stream' ),
array(
'action' => $is_new,
'id' => $id,
'title' => $title,
'action' => $is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
),
$id,
'forms',
@@ -255,16 +251,12 @@ public function callback_gform_pre_confirmation_save( $confirmation, $form, $is_
}

$this->log(
sprintf(
/* translators: %1$s: a confirmation name, %2$s: a status, %3$s: a form title (e.g. "Email", "created", "Contact Form") */
__( '"%1$s" confirmation %2$s for "%3$s"', 'stream' ),
$confirmation['name'],
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
$form['title']
),
/* translators: %1$s: a confirmation name, %2$s: a status, %3$s: a form title (e.g. "Email", "created", "Contact Form") */
__( '"%1$s" confirmation %2$s for "%3$s"', 'stream' ),
array(
'is_new' => $is_new,
'form_id' => $form['id'],
'title' => $confirmation['name'],
'action' => $is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
'form_title' => $form['title'],
),
$form['id'],
'forms',
@@ -288,16 +280,12 @@ public function callback_gform_pre_notification_save( $notification, $form, $is_
}

$this->log(
sprintf(
/* translators: %1$s: a notification name, %2$s: a status, %3$s: a form title (e.g. "Email", "created", "Contact Form") */
__( '"%1$s" notification %2$s for "%3$s"', 'stream' ),
$notification['name'],
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
$form['title']
),
/* translators: %1$s: a notification name, %2$s: a status, %3$s: a form title (e.g. "Email", "created", "Contact Form") */
__( '"%1$s" notification %2$s for "%3$s"', 'stream' ),
array(
'is_update' => $is_new,
'form_id' => $form['id'],
'title' => $notification['name'],
'action' => $is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
'form_title' => $form['title'],
),
$form['id'],
'forms',
@@ -315,15 +303,11 @@ public function callback_gform_pre_notification_save( $notification, $form, $is_
*/
public function callback_gform_pre_notification_deleted( $notification, $form ) {
$this->log(
sprintf(
/* translators: %1$s: a notification name, %2$s: a form title (e.g. "Email", "Contact Form") */
__( '"%1$s" notification deleted from "%2$s"', 'stream' ),
$notification['name'],
$form['title']
),
/* translators: %1$s: a notification name, %2$s: a form title (e.g. "Email", "Contact Form") */
__( '"%1$s" notification deleted from "%2$s"', 'stream' ),
array(
'form_id' => $form['id'],
'notification' => $notification,
'title' => $notification['name'],
'form_title' => $form['title'],
),
$form['id'],
'forms',
@@ -339,15 +323,11 @@ public function callback_gform_pre_notification_deleted( $notification, $form )
*/
public function callback_gform_pre_confirmation_deleted( $confirmation, $form ) {
$this->log(
sprintf(
/* translators: %1$s: a confirmation name, %2$s: a form title (e.g. "Email", "Contact Form") */
__( '"%1$s" confirmation deleted from "%2$s"', 'stream' ),
$confirmation['name'],
$form['title']
),
/* translators: %1$s: a confirmation name, %2$s: a form title (e.g. "Email", "Contact Form") */
__( '"%1$s" confirmation deleted from "%2$s"', 'stream' ),
array(
'form_id' => $form['id'],
'confirmation' => $confirmation,
'title' => $confirmation['name'],
'form_title' => $form['title'],
),
$form['id'],
'forms',
@@ -361,6 +341,9 @@ public function callback_gform_pre_confirmation_deleted( $confirmation, $form )
* @param array $confirmation Confirmation data.
* @param array $form Form data.
* @param bool $is_active Is this form active?.
*
* @TODO See if this needs to be removed.
* Can't find action or logic relating to status of the confirmation in the GF code.
*/
public function callback_gform_confirmation_status( $confirmation, $form, $is_active ) {
$this->log(
@@ -388,6 +371,9 @@ public function callback_gform_confirmation_status( $confirmation, $form, $is_ac
* @param array $notification Notification data.
* @param array $form Form data.
* @param bool $is_active Is this form active?.
*
* @TODO See if this needs to be removed.
* Can't find action or logic relating to status of the confirmation in the GF code.
*/
public function callback_gform_notification_status( $notification, $form, $is_active ) {
$this->log(
@@ -581,32 +567,31 @@ public function callback_gform_forms_post_import( $forms ) {
*
* @action gform_export_separator
*
* @param string $dummy Unused.
* @param int $form_id Form ID.
* @param array $form Form object.
*/
public function callback_gform_export_separator( $dummy, $form_id ) {
$form = $this->get_form( $form_id );

public function callback_gform_export_form( $form ) {
$this->log(
/* translators: %s: a form title (e.g. "Contact Form") */
__( '"%s" form exported', 'stream' ),
array(
'form_title' => $form['title'],
'form_id' => $form_id,
'form_id' => $form['id'],
),
$form_id,
$form['id'],
'export',
'exported'
);

return $dummy;
return $form;
}

/**
* Log bulk form exports
*
* @param string $dummy Unused.
* @param array $forms Form data.
*
* @TODO See if this callback should be removed.
*/
public function callback_gform_export_options( $dummy, $forms ) {
$ids = wp_list_pluck( $forms, 'id' );
@@ -746,17 +731,12 @@ public function callback_gform_update_status( $lead_id, $status, $prev = '' ) {
}

$this->log(
sprintf(
/* translators: %1$d: an ID, %2$s: a status, %3$s: a form title (e.g. "42", "activated", "Contact Form") */
__( 'Lead #%1$d %2$s on "%3$s" form', 'stream' ),
$lead_id,
$actions[ $status ],
$form['title']
),
/* translators: %1$d: an ID, %2$s: a status, %3$s: a form title (e.g. "42", "activated", "Contact Form") */
__( 'Lead #%1$d %2$s on "%3$s" form', 'stream' ),
array(
'lead_id' => $lead_id,
'action' => $actions[ $status ],
'form_title' => $form['title'],
'form_id' => $form['id'],
'status' => $status,
'prev' => $prev,
),
@@ -780,14 +760,8 @@ public function callback_gform_update_is_read( $lead_id, $status ) {
$status = ( ! empty( $status ) ) ? esc_html__( 'read', 'stream' ) : esc_html__( 'unread', 'stream' );

$this->log(
sprintf(
/* translators: %1$d: a lead ID, %2$s: a status, %3$s: a form ID, %4$s: a form title (e.g. "42", "unread", "Contact Form") */
__( 'Entry #%1$d marked as %2$s on form #%3$d ("%4$s")', 'stream' ),
$lead_id,
$status,
$form['id'],
$form['title']
),
/* translators: %1$d: a lead ID, %2$s: a status, %3$s: a form ID, %4$s: a form title (e.g. "42", "unread", "Contact Form") */
__( 'Entry #%1$d marked as %2$s on form #%3$d ("%4$s")', 'stream' ),
array(
'lead_id' => $lead_id,
'lead_status' => $status,
@@ -815,14 +789,8 @@ public function callback_gform_update_is_starred( $lead_id, $status ) {
$action = $status;

$this->log(
sprintf(
/* translators: %1$d: an ID, %2$s: a status, %3$d: a form title (e.g. "42", "starred", "Contact Form") */
__( 'Entry #%1$d %2$s on form #%3$d ("%4$s")', 'stream' ),
$lead_id,
$status,
$form['id'],
$form['title']
),
/* translators: %1$d: an ID, %2$s: a status, %3$d: a form title (e.g. "42", "starred", "Contact Form") */
__( 'Entry #%1$d %2$s on form #%3$d ("%4$s")', 'stream' ),
array(
'lead_id' => $lead_id,
'lead_status' => $status,
@@ -936,17 +904,12 @@ public function log_form_action( $form_id, $action ) {
);

$this->log(
sprintf(
/* translators: %1$d: an ID, %2$s: a form title, %3$s: a status (e.g. "42", "Contact Form", "Activated") */
__( 'Form #%1$d ("%2$s") %3$s', 'stream' ),
$form_id,
$form['title'],
strtolower( $actions[ $action ] )
),
/* translators: %1$d: an ID, %2$s: a form title, %3$s: a status (e.g. "42", "Contact Form", "Activated") */
__( 'Form #%1$d ("%2$s") %3$s', 'stream' ),
array(
'form_id' => $form_id,
'form_title' => $form['title'],
'form_status' => strtolower( $action ),
'form_status' => strtolower( $actions[ $action ] ),
),
$form['id'],
'forms',
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
<php>
<const
name="WP_TEST_ACTIVATED_PLUGINS"
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,user-switching/user-switching.php"
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,user-switching/user-switching.php,gravityforms/gravityforms.php"
/>
</php>
<testsuites>
1,063 changes: 1,063 additions & 0 deletions tests/tests/connectors/test-class-connector-gravityforms.php

Large diffs are not rendered by default.