Skip to content

Commit

Permalink
edd-connector test added.
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Aug 14, 2020
1 parent 11612bf commit 2514b6b
Show file tree
Hide file tree
Showing 5 changed files with 367 additions and 53 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"wp-coding-standards/wpcs": "^2.2",
"wp-phpunit/wp-phpunit": "^5.4",
"wpsh/local": "^0.2.3",
"wpackagist-plugin/advanced-custom-fields": "5.8.12"
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "^2.9.23"
},
"config": {
"process-timeout": 600,
Expand Down
85 changes: 57 additions & 28 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 20 additions & 23 deletions connectors/class-connector-edd.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,8 @@ public function check( $option, $old_value, $new_value ) {
$replacement = str_replace( '-', '_', $option );

if ( method_exists( $this, 'check_' . $replacement ) ) {
call_user_func(
array(
$this,
'check_' . $replacement,
),
$old_value,
$new_value
);
$method = "check_{$replacement}";
$this->{$method}( $old_value, $new_value );
} else {
$data = $this->options[ $option ];
$option_title = $data['label'];
Expand Down Expand Up @@ -376,17 +370,21 @@ public function check_edd_settings( $old_value, $new_value ) {

foreach ( $options as $option => $option_value ) {
$field = null;
$tab = null;

if ( 'banned_email' === $option ) {
$field = array(
'name' => esc_html_x( 'Banned emails', 'edd', 'stream' ),
);
$tab = 'general';
} else {
foreach ( $settings as $tab => $fields ) {
if ( isset( $fields[ $option ] ) ) {
$field = $fields[ $option ];
break;
foreach ( $settings as $current_tab => $tab_sections ) {
foreach ( $tab_sections as $section => $section_fields ) {
if ( in_array( $option, array_keys( $section_fields ), true ) ) {
$field = $section_fields[ $option ];
$tab = $current_tab;
break;
}
}
}
}
Expand All @@ -401,8 +399,8 @@ public function check_edd_settings( $old_value, $new_value ) {
array(
'option_title' => $field['name'],
'option' => $option,
'old_value' => $old_value,
'value' => $new_value,
'old_value' => isset( $old_value[ $option ] ) ? $old_value[ $option ] : null,
'value' => isset( $new_value[ $option ] ) ? $new_value[ $option ] : null,
'tab' => $tab,
),
null,
Expand Down Expand Up @@ -652,6 +650,12 @@ public function callback_delete_user_meta( $meta_id, $object_id, $meta_key, $_me
* @param bool $is_add Is this a new meta?.
*/
public function meta( $object_id, $key, $value, $is_add = false ) {
// For catching "edd_user_public_key" in newer versions of EDD.
if ( in_array( $value, $this->user_meta, true ) ) {
$key = $value;
$value = 1; // Probably, should avoid storing the api key.
}

if ( ! in_array( $key, $this->user_meta, true ) ) {
return false;
}
Expand All @@ -662,15 +666,8 @@ public function meta( $object_id, $key, $value, $is_add = false ) {
return false;
}

return call_user_func(
array(
$this,
'meta_' . $key,
),
$object_id,
$value,
$is_add
);
$method = "meta_{$key}";
return $this->{$method}( $object_id, $value, $is_add );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<php>
<const
name="WP_TEST_ACTIVATED_PLUGINS"
value="advanced-custom-fields/acf.php"
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php"
/>
</php>
<testsuites>
Expand Down
Loading

0 comments on commit 2514b6b

Please sign in to comment.