Skip to content

Commit

Permalink
Add tests for email token length too
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparsd committed Dec 2, 2024
1 parent bbcd041 commit 61a7489
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/providers/class-two-factor-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,24 @@ public function test_tokens_can_expire() {
);
}

public function test_custom_token_length() {
$user_id = self::factory()->user->create();

$default_token = $this->provider->generate_token( $user_id );

add_filter(
'two_factor_token_length',
function() {
return 15;
}
);

$custom_token = $this->provider->generate_token( $user_id );

$this->assertNotEquals( strlen( $default_token ), strlen( $custom_token ), 'Token length is different due to filter' );
$this->assertEquals( 15, strlen( $custom_token ), 'Token length matches the filter value' );

remove_all_filters( 'two_factor_token_length' );
}

}

0 comments on commit 61a7489

Please sign in to comment.