Skip to content

Commit

Permalink
Add tests for the email token TTL filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Jan 9, 2025
1 parent 33f0060 commit 12571b1
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/providers/class-two-factor-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,47 @@ function() {
remove_all_filters( 'two_factor_email_token_length' );
}

/**
* Test the email token TTL.
*
* @expectedDeprecated two_factor_token_ttl
*/
public function test_email_token_ttl() {
$this->assertEquals(
15 * MINUTE_IN_SECONDS,
$this->provider->user_token_ttl( 123 ),
'The email token matches the default TTL'
);

add_filter(
'two_factor_email_token_ttl',
function() {
return 42;
}
);

$this->assertEquals(
42,
$this->provider->user_token_ttl( 123 ),
'The email token ttl can be filtered'
);

remove_all_filters( 'two_factor_email_token_ttl' );

add_filter(
'two_factor_token_ttl',
function() {
return 66;
}
);

$this->assertEquals(
66,
$this->provider->user_token_ttl( 123 ),
'The email token matches can be filtered with the deprecated filter'
);

remove_all_filters( 'two_factor_token_ttl' );
}

}

0 comments on commit 12571b1

Please sign in to comment.