From 0964167f1286d5e4c04bbec6fbfc78ece4198303 Mon Sep 17 00:00:00 2001 From: Ian Dunn Date: Mon, 29 Aug 2022 15:42:13 -0700 Subject: [PATCH] Apply coding standards --- plugins/wporg-5ftf/includes/contributor.php | 1 + plugins/wporg-5ftf/includes/stats.php | 2 +- plugins/wporg-5ftf/tests/helpers.php | 25 +++++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/plugins/wporg-5ftf/includes/contributor.php b/plugins/wporg-5ftf/includes/contributor.php index 9a8ccc9..7e8a3e3 100644 --- a/plugins/wporg-5ftf/includes/contributor.php +++ b/plugins/wporg-5ftf/includes/contributor.php @@ -790,6 +790,7 @@ function prune_unnotifiable_users( array $contributors ) : array { * Determine if a contributor is active or not. * * Currently this only tracks the last login, but in the future it will be expanded to be more granular. + * * @link https://github.com/WordPress/five-for-the-future/issues/210 */ function is_active( int $last_login ) : bool { diff --git a/plugins/wporg-5ftf/includes/stats.php b/plugins/wporg-5ftf/includes/stats.php index cea20fa..eadf226 100644 --- a/plugins/wporg-5ftf/includes/stats.php +++ b/plugins/wporg-5ftf/includes/stats.php @@ -157,7 +157,7 @@ function get_snapshot_data() { $team_contributor_key = sprintf( 'team_%s_contributors', $attribution_prefix ); - $snapshot_data[ $attribution_prefix . '_hours'] += $user['hours_per_week']; + $snapshot_data[ $attribution_prefix . '_hours' ] += $user['hours_per_week']; foreach ( $user['team_names'] as $team ) { if ( isset( $snapshot_data[ $team_contributor_key ][ $team ] ) ) { diff --git a/plugins/wporg-5ftf/tests/helpers.php b/plugins/wporg-5ftf/tests/helpers.php index 175ec54..0ec38a9 100644 --- a/plugins/wporg-5ftf/tests/helpers.php +++ b/plugins/wporg-5ftf/tests/helpers.php @@ -28,28 +28,28 @@ function database_setup_before_class( WP_UnitTest_Factory $factory ) : array { ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 " ); - // Users + // Users. $fixtures['users']['jane'] = $factory->user->create_and_get( array( 'user_login' => 'jane', 'user_email' => 'jane@example.org', 'meta_input' => array( - 'last_logged_in' => date( 'Y-m-d H:i:s', strtotime( '95 days ago' ) ) - ) + 'last_logged_in' => gmdate( 'Y-m-d H:i:s', strtotime( '95 days ago' ) ), + ), ) ); $fixtures['users']['ashish'] = $factory->user->create_and_get( array( 'user_login' => 'ashish', 'user_email' => 'ashish@example.org', 'meta_input' => array( - 'last_logged_in' => date( 'Y-m-d H:i:s', strtotime( '2 hours ago' ) ) - ) + 'last_logged_in' => gmdate( 'Y-m-d H:i:s', strtotime( '2 hours ago' ) ), + ), ) ); // Some users don't have any of the expected fields, so make sure they're included in tests. $fixtures['users']['kimi'] = $factory->user->create_and_get( array( 'user_login' => 'kimi', 'user_email' => 'kimi@example.org', - 'meta_input' => array() + 'meta_input' => array(), ) ); delete_user_meta( $fixtures['users']['kimi']->ID, 'first_name' ); @@ -57,28 +57,29 @@ function database_setup_before_class( WP_UnitTest_Factory $factory ) : array { 'user_login' => 'andrea', 'user_email' => 'andrea@example.org', 'meta_input' => array( - 'last_logged_in' => date( 'Y-m-d H:i:s', strtotime( '1 week ago' ) ) - ) + 'last_logged_in' => gmdate( 'Y-m-d H:i:s', strtotime( '1 week ago' ) ), + ), ) ); $fixtures['users']['caleb'] = $factory->user->create_and_get( array( 'user_login' => 'caleb', 'user_email' => 'caleb@example.org', 'meta_input' => array( - 'last_logged_in' => date( 'Y-m-d H:i:s', strtotime( '4 months ago' ) ) - ) + 'last_logged_in' => gmdate( 'Y-m-d H:i:s', strtotime( '4 months ago' ) ), + ), ) ); - // Pages + // Pages. $for_organizations = $factory->post->create_and_get( array( 'post_type' => 'page', 'post_title' => 'For Organizations', 'post_status' => 'publish', ) ); $fixtures['pages']['for_organizations'] = $for_organizations; + // phpcs:ignore -- Overriding the global is required to mock a real environment. $GLOBALS['post'] = $for_organizations; // `create_new_pledge()` assumes this exists. - // Pledges + // Pledges. $tenup_id = Pledge\create_new_pledge( '10up' ); $bluehost_id = Pledge\create_new_pledge( 'BlueHost' );