Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Aug 5, 2023
1 parent 8b53e44 commit f54d9f6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .tests/php/unit/Settings/GeneralTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -206,8 +219,6 @@ public function dp_test_section_callback() {
' <h2>
General </h2>
<div id="hcaptcha-message"></div>
<p>
To use <a href="https://www.hcaptcha.com/?r=wp&utm_source=wordpress&utm_medium=wpplugin&utm_campaign=sk" target="_blank">hCaptcha</a>, please register <a href="https://www.hcaptcha.com/signup-interstitial/?r=wp&utm_source=wordpress&utm_medium=wpplugin&utm_campaign=sk" target="_blank">here</a> to get your site and secret keys. </p>
<h3 class="hcaptcha-section-keys">Keys</h3>
',
],
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f54d9f6

Please sign in to comment.