mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-22 11:03:43 +03:00
parent
04413b9f6c
commit
2880d80e12
|
@ -7,6 +7,8 @@
|
|||
namespace {
|
||||
defined( 'WPINC' ) || die();
|
||||
|
||||
define( 'WPORG_SUPPORT_FORUMS_BLOGID', 419 );
|
||||
|
||||
/**
|
||||
* Stub.
|
||||
*/
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -13,6 +13,7 @@ plugins/*
|
|||
themes/wporg-5ftf/css/style.css
|
||||
themes/wporg-5ftf/css/style-editor.css
|
||||
themes/pub
|
||||
themes/twenty*
|
||||
|
||||
/uploads
|
||||
/db.php
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
}
|
||||
},
|
||||
"require": {},
|
||||
"_comment" : "PHPUnit 7.x is the latest version that's compatible with Core, see https://core.trac.wordpress.org/ticket/46149",
|
||||
"require-dev" : {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
|
||||
"wp-coding-standards/wpcs": "2.3.*",
|
||||
|
|
|
@ -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 );
|
||||
|
||||
$this->assertSame( $expected, array_keys( $actual ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue