mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 10:05:43 +03:00
Contributors: Modularize activity detection for reuse.
This commit is contained in:
parent
44e9daccd9
commit
ccad917c00
2 changed files with 49 additions and 2 deletions
|
@ -5,10 +5,12 @@ use WordPressDotOrg\FiveForTheFuture\{ Contributor, Pledge, XProfile };
|
|||
defined( 'WPINC' ) || die();
|
||||
|
||||
/**
|
||||
* These are integration tests rather than unit tests. They target the the highest functions in the call stack
|
||||
* Some of these are integration tests rather than unit tests. They target the the highest functions in the call stack
|
||||
* in order to test everything beneath them, to the extent that that's practical. `INPUT_POST` can't be mocked,
|
||||
* so functions that reference it can't be used.
|
||||
*
|
||||
* Mocking that can become unwieldy, though, so sometimes unit tests are more practical.
|
||||
*
|
||||
* @group contributor
|
||||
*/
|
||||
class Test_Contributor extends WP_UnitTestCase {
|
||||
|
@ -265,4 +267,37 @@ class Test_Contributor extends WP_UnitTestCase {
|
|||
$this->assertContains( $jane->user_email, $mailer->mock_sent[0]['to'][0] );
|
||||
$this->assertSame( "Removed from $tenup->post_title Five for the Future pledge", $mailer->mock_sent[0]['subject'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::prune_unnotifiable_users
|
||||
*/
|
||||
public function test_prune_unnotifiable_users() {
|
||||
$contributors = array(
|
||||
'active + due for email' => array(
|
||||
'last_logged_in' => strtotime( '1 week ago' ),
|
||||
'5ftf_last_inactivity_email' => 0,
|
||||
),
|
||||
|
||||
'active + not due for email' => array(
|
||||
'last_logged_in' => strtotime( '1 week ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '1 month ago' ),
|
||||
),
|
||||
|
||||
'inactive + due for email' => array(
|
||||
'last_logged_in' => strtotime( '4 months ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '4 months ago' ),
|
||||
),
|
||||
|
||||
'inactive + not due for email' => array(
|
||||
'last_logged_in' => strtotime( '4 months ago' ),
|
||||
'5ftf_last_inactivity_email' => strtotime( '2 months ago' ),
|
||||
),
|
||||
);
|
||||
|
||||
$expected = array( 'inactive + due for email' );
|
||||
|
||||
$actual = Contributor\prune_unnotifiable_users( $contributors );
|
||||
|
||||
$this->assertSame( $expected, array_keys( $actual ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue