From f54d9f682c8201beddd645c6c04f6f55ceb61308 Mon Sep 17 00:00:00 2001 From: kagg-design Date: Sat, 5 Aug 2023 19:51:20 +0300 Subject: [PATCH] Fix tests. --- .tests/php/unit/Settings/GeneralTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.tests/php/unit/Settings/GeneralTest.php b/.tests/php/unit/Settings/GeneralTest.php index 177cf033..8451b05a 100644 --- a/.tests/php/unit/Settings/GeneralTest.php +++ b/.tests/php/unit/Settings/GeneralTest.php @@ -12,6 +12,7 @@ namespace HCaptcha\Tests\Unit\Settings; +use HCaptcha\Admin\Notifications; use HCaptcha\Main; use HCaptcha\Settings\Abstracts\SettingsBase; use HCaptcha\Settings\General; @@ -187,6 +188,18 @@ public function test_setup_fields_not_on_options_screen() { public function test_section_callback( $section_id, $expected ) { $subject = Mockery::mock( General::class )->makePartial()->shouldAllowMockingProtectedMethods(); + $notifications = Mockery::mock( Notifications::class )->makePartial(); + + if ( General::SECTION_KEYS === $section_id ) { + $notifications->shouldReceive( 'show' )->once(); + $main = Mockery::mock( Main::class )->makePartial(); + $main->shouldReceive( 'notifications' )->andReturn( $notifications ); + + WP_Mock::userFunction( 'hcaptcha' )->with()->once()->andReturn( $main ); + } else { + WP_Mock::userFunction( 'hcaptcha' )->never(); + } + WP_Mock::passthruFunction( 'wp_kses_post' ); ob_start(); @@ -206,8 +219,6 @@ public function dp_test_section_callback() { '

General

-

- To use hCaptcha, please register here to get your site and secret keys.

Keys

', ], @@ -297,7 +308,7 @@ static function ( $name ) use ( $plugin_url, $plugin_version ) { General::OBJECT, [ 'ajaxUrl' => $ajax_url, - 'action' => General::CHECK_CONFIG_ACTION, + 'checkConfigAction' => General::CHECK_CONFIG_ACTION, 'nonce' => $nonce, 'modeLive' => General::MODE_LIVE, 'modeTestPublisher' => General::MODE_TEST_PUBLISHER,