mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 10:05:43 +03:00
parent
04413b9f6c
commit
2880d80e12
6 changed files with 36 additions and 5 deletions
|
@ -795,6 +795,15 @@ function prune_unnotifiable_users( array $contributors ) : array {
|
|||
unset( $contributors[ $index ] );
|
||||
continue;
|
||||
}
|
||||
|
||||
// bbPress is not active on this site, so fetch it directly from the database.
|
||||
global $wpdb;
|
||||
$forums_role = get_user_meta( $contributor['user_id'], $wpdb->base_prefix . WPORG_SUPPORT_FORUMS_BLOGID . '_capabilities', true );
|
||||
|
||||
if ( isset( $forums_role['bbp_blocked'] ) && true === $forums_role['bbp_blocked'] ) {
|
||||
unset( $contributors[ $index ] );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return $contributors;
|
||||
|
|
|
@ -21,7 +21,9 @@ require_once $_tests_dir . '/includes/functions.php';
|
|||
* Manually load the plugin being tested.
|
||||
*/
|
||||
function _manually_load_plugin() {
|
||||
require dirname( dirname( __FILE__ ) ) . '/index.php';
|
||||
define( 'WPORG_SUPPORT_FORUMS_BLOGID', 1 );
|
||||
|
||||
require dirname( __FILE__, 2 ) . '/index.php';
|
||||
require __DIR__ . '/helpers.php';
|
||||
}
|
||||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
||||
|
|
|
@ -217,42 +217,60 @@ class Test_Contributor extends WP_UnitTestCase {
|
|||
* @covers WordPressDotOrg\FiveForTheFuture\Contributor\prune_unnotifiable_users
|
||||
*/
|
||||
public function test_prune_unnotifiable_users() {
|
||||
global $wpdb;
|
||||
|
||||
update_user_meta(
|
||||
self::$users['kimi']->ID,
|
||||
$wpdb->base_prefix . WPORG_SUPPORT_FORUMS_BLOGID . '_capabilities',
|
||||
array( 'bbp_blocked' => true )
|
||||
);
|
||||
|
||||
$contributors = array(
|
||||
'active + due for email' => array(
|
||||
'user_id' => self::$users['jane']->ID,
|
||||
'last_logged_in' => strtotime( '1 week ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
'5ftf_last_inactivity_email' => 0,
|
||||
),
|
||||
|
||||
'active + not due for email' => array(
|
||||
'user_id' => self::$users['ashish']->ID,
|
||||
'last_logged_in' => strtotime( '1 week ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '1 month ago' ),
|
||||
),
|
||||
|
||||
'inactive + due for email' => array(
|
||||
'user_id' => self::$users['andrea']->ID,
|
||||
'last_logged_in' => strtotime( '4 months ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '4 months ago' ),
|
||||
),
|
||||
|
||||
'inactive + not due for email' => array(
|
||||
'user_id' => self::$users['caleb']->ID,
|
||||
'last_logged_in' => strtotime( '4 months ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '2 months ago' ),
|
||||
),
|
||||
|
||||
'new user' => array(
|
||||
'user_id' => self::$users['jane']->ID,
|
||||
'last_logged_in' => 0,
|
||||
'user_registered' => strtotime( '1 week ago' ),
|
||||
'5ftf_last_inactivity_email' => 0,
|
||||
),
|
||||
|
||||
'inactive + blocked' => array(
|
||||
'user_id' => self::$users['kimi']->ID,
|
||||
'last_logged_in' => strtotime( '4 months ago' ),
|
||||
'user_registered' => strtotime( '1 year ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '4 months ago' ),
|
||||
),
|
||||
);
|
||||
|
||||
$expected = array( 'inactive + due for email' );
|
||||
|
||||
$actual = Contributor\prune_unnotifiable_users( $contributors );
|
||||
|
||||
$actual = Contributor\prune_unnotifiable_users( $contributors );
|
||||
$this->assertSame( $expected, array_keys( $actual ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue