Skip to content

Commit

Permalink
Restore 100% test coverage of Wordfence.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Aug 24, 2024
1 parent 6c7a88c commit 5e0d71b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .tests/php/integration/Wordfence/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use HCaptcha\Wordfence\General;
use HCaptcha\WP\Login;
use ReflectionException;
use tad\FunctionMocker\FunctionMocker;

/**
* Test General class.
Expand Down Expand Up @@ -130,4 +131,41 @@ public function test_remove_wp_login_hcaptcha_hooks(): void {
self::assertFalse( has_action( 'login_form', [ $wp_login, 'add_captcha' ] ) );
self::assertFalse( has_filter( 'wp_authenticate_user', [ $wp_login, 'check_signature' ] ) );
}

/**
* Test print_inline_styles().
*
* @return void
* @noinspection CssUnusedSymbol
*/
public function test_print_inline_styles(): void {
FunctionMocker::replace(
'defined',
static function ( $constant_name ) {
return 'SCRIPT_DEBUG' === $constant_name;
}
);

FunctionMocker::replace(
'constant',
static function ( $name ) {
return 'SCRIPT_DEBUG' === $name;
}
);

$expected = <<<CSS
#loginform[style="position: relative;"] > .h-captcha {
visibility: hidden !important;
}
CSS;
$expected = "<style>\n$expected\n</style>\n";

$subject = new General();

ob_start();

$subject->print_inline_styles();

self::assertSame( $expected, ob_get_clean() );
}
}

0 comments on commit 5e0d71b

Please sign in to comment.