Skip to content

Commit

Permalink
Merge pull request #1153 from xwp/tests/jetpack-connector
Browse files Browse the repository at this point in the history
Jetpack connector test implemented
  • Loading branch information
kidunot89 committed Mar 26, 2021
2 parents 2c05fb5 + f75574b commit ea3c7fd
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 10 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"wp-phpunit/wp-phpunit": "^5.4",
"wpackagist-plugin/advanced-custom-fields": "5.8.12",
"wpackagist-plugin/easy-digital-downloads": "^2.9.23",
"wpackagist-plugin/jetpack": "^8.7",
"wpackagist-plugin/user-switching": "^1.5.5",
"wpsh/local": "^0.2.3"
},
Expand Down
20 changes: 19 additions & 1 deletion composer.lock

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

14 changes: 9 additions & 5 deletions connectors/class-connector-jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,16 @@ public function register() {
'label' => esc_html__( 'Tiled Galleries', 'stream' ),
'context' => 'tiled-gallery',
),
// Monitor.
'monitor_receive_notification' => array(
'label' => esc_html__( 'Monitor notifications', 'stream' ),
'context' => 'monitor',
),
);
}

/**
* Track Jetpack log entries
* Tracks logs add to Jetpack logging.
* Includes:
* - Activation/Deactivation of modules
* - Registration/Disconnection of blogs
Expand Down Expand Up @@ -374,11 +379,10 @@ public function callback_jetpack_log_entry( array $entry ) {
$action = $method;
$meta = compact( 'user_id', 'user_email', 'user_login' );
$message = sprintf(
/* translators: %1$s: a user display name, %2$s: a status, %3$s: the connection either "from" or "to" (e.g. "Jane Doe", "unlinked", "from") */
__( '%1$s\'s account %2$s %3$s Jetpack', 'stream' ),
/* translators: %1$s: a user display name, %2$s: a status and the connection either "from" or "to" (e.g. "Jane Doe", "unlinked from") */
__( '%1$s\'s account %2$s Jetpack', 'stream' ),
$user->display_name,
( 'unlink' === $action ) ? esc_html__( 'unlinked', 'stream' ) : esc_html__( 'linked', 'stream' ),
( 'unlink' === $action ) ? esc_html__( 'from', 'stream' ) : esc_html__( 'to', 'stream' )
( 'unlink' === $action ) ? esc_html__( 'unlinked from', 'stream' ) : esc_html__( 'linked to', 'stream' )
);
} elseif ( in_array( $method, array( 'register', 'disconnect', 'subsiteregister', 'subsitedisconnect' ), true ) ) {
$context = 'blogs';
Expand Down
3 changes: 2 additions & 1 deletion local/config/wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

$table_prefix = 'wptests_';

define( 'WP_DEBUG', false );
define( 'WP_DEBUG', true );
define( 'JETPACK_DEV_DEBUG', true );

define( 'ABSPATH', __DIR__ . '/' );

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,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,jetpack/jetpack.php,user-switching/user-switching.php"
/>
</php>
<testsuites>
Expand Down
12 changes: 10 additions & 2 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ function() {
}
);

/**
* Manually loads Mercator for testing.
*/
function xwp_manually_load_mercator() {
define( 'MERCATOR_SKIP_CHECKS', true );
require WPMU_PLUGIN_DIR . '/mercator/mercator.php';
}

tests_add_filter( 'muplugins_loaded', 'xwp_manually_load_mercator' );

/**
* Manually creates EDD's database tables, users, and settings for testing.
*/
function xwp_install_edd() {
// Install Easy Digital Downloads

edd_install();

global $current_user, $edd_options;
Expand All @@ -79,6 +84,9 @@ function( $status = false, $args = array(), $url = '') {
);
}

// Run Jetpack in offline mode for testing.
tests_add_filter( 'jetpack_offline_mode', '__return_true' );

// @see https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/bootstrap.php
require $_tests_dir . '/includes/bootstrap.php';

Expand Down

0 comments on commit ea3c7fd

Please sign in to comment.