From 5aece8098df4b7bf5f947b918002276d8aa09f9b Mon Sep 17 00:00:00 2001 From: kagg-design Date: Mon, 22 Jul 2024 00:29:45 +0300 Subject: [PATCH] Upgrade integration tests to PHP 7.2. --- .tests/php/integration/AAAMainTest.php | 42 +++++++-------- .tests/php/integration/ACFE/FormTest.php | 20 +++---- .../integration/Admin/Events/EventsTest.php | 24 ++++----- .../integration/Admin/NotificationsTest.php | 24 ++++----- .../integration/AutoVerify/AutoVerifyTest.php | 42 +++++++-------- .tests/php/integration/Avada/FormTest.php | 11 ++-- .../php/integration/BBPress/NewTopicTest.php | 8 +-- .tests/php/integration/BBPress/ReplyTest.php | 8 +-- .../BuddyPress/CreateGroupTest.php | 13 ++--- .../integration/BuddyPress/RegisterTest.php | 10 ++-- .tests/php/integration/CF7/AdminTest.php | 14 ++--- .tests/php/integration/CF7/CF7Test.php | 2 +- .../DelayedScript/DelayedScriptTest.php | 4 +- .tests/php/integration/Divi/CommentTest.php | 10 ++-- .tests/php/integration/Divi/ContactTest.php | 23 ++++---- .../php/integration/Divi/EmailOptinTest.php | 14 ++--- .tests/php/integration/Divi/LoginTest.php | 8 +-- .../ElementorPro/HCaptchaHandlerTest.php | 52 +++++++++---------- .../php/integration/FluentForm/FormTest.php | 10 ++-- .../integration/GravityForms/FieldTest.php | 23 ++++---- .../php/integration/GravityForms/FormTest.php | 25 ++++----- .../integration/HCaptchaPluginWPTestCase.php | 4 +- .tests/php/integration/HCaptchaWPTestCase.php | 19 ++++--- .../php/integration/Helpers/HCaptchaTest.php | 18 +++---- .../php/integration/Helpers/RequestTest.php | 5 +- .../integration/Jetpack/JetpackBaseTest.php | 8 +-- .../integration/Jetpack/JetpackFormTest.php | 2 +- .tests/php/integration/Mailchimp/FormTest.php | 8 +-- .tests/php/integration/MainPluginFileTest.php | 6 +-- .../integration/MemberPress/RegisterTest.php | 8 +-- .../integration/Migrations/MigrationsTest.php | 14 ++--- .tests/php/integration/NF/FieldTest.php | 10 ++-- .tests/php/integration/NF/NFTest.php | 10 ++-- .tests/php/integration/Stubs/GFFormsModel.php | 5 ++ .tests/php/integration/Stubs/GF_Fields.php | 1 + .../php/integration/Subscriber/FormTest.php | 6 +-- .tests/php/integration/UM/LoginTest.php | 16 +++--- .../php/integration/UM/LostPasswordTest.php | 8 ++- .tests/php/integration/UM/RegisterTest.php | 6 +-- .tests/php/integration/WC/CheckoutTest.php | 18 +++---- .tests/php/integration/WC/LoginTest.php | 19 ++++--- .../php/integration/WC/LostPasswordTest.php | 7 +-- .../php/integration/WC/OrderTrackingTest.php | 6 +-- .tests/php/integration/WC/RegisterTest.php | 11 ++-- .../WCWishlists/CreateListTest.php | 6 +-- .tests/php/integration/WP/CommentTest.php | 26 +++++----- .tests/php/integration/WP/LoginTest.php | 39 +++++++------- .../php/integration/WP/LostPasswordTest.php | 19 +++---- .../integration/WP/PasswordProtectedTest.php | 18 +++---- .tests/php/integration/WP/RegisterTest.php | 19 +++---- .../php/integration/WPDiscuz/CommentTest.php | 17 +++--- .../integration/WPDiscuz/SubscribeTest.php | 18 +++---- .tests/php/integration/WPForms/FormTest.php | 31 +++++------ .../php/integration/WPForo/NewTopicTest.php | 17 +++--- .tests/php/integration/WPForo/ReplyTest.php | 10 ++-- .../integration/WPJobOpenings/FormTest.php | 14 ++--- .../php/integration/Wordfence/GeneralTest.php | 8 +-- .../integration/includes/FunctionsTest.php | 2 +- .../php/integration/includes/RequestTest.php | 50 ++++++++---------- .tests/php/unit/AutoVerify/AutoVerifyTest.php | 2 +- .tests/php/unit/HCaptchaTestCase.php | 4 +- .tests/php/unit/Settings/GeneralTest.php | 2 +- .tests/php/unit/Settings/SystemInfoTest.php | 2 +- 63 files changed, 441 insertions(+), 465 deletions(-) diff --git a/.tests/php/integration/AAAMainTest.php b/.tests/php/integration/AAAMainTest.php index 8d299104..3cfeab59 100644 --- a/.tests/php/integration/AAAMainTest.php +++ b/.tests/php/integration/AAAMainTest.php @@ -67,7 +67,7 @@ class AAAMainTest extends HCaptchaWPTestCase { * * @throws ReflectionException ReflectionException. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { $hcaptcha = hcaptcha(); $loaded_classes = $this->get_protected_property( $hcaptcha, 'loaded_classes' ); @@ -105,7 +105,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl * * @return void */ - public function test_init() { + public function test_init(): void { $hcaptcha = hcaptcha(); // The plugin was loaded by codeception. @@ -133,7 +133,7 @@ public function test_init() { * @noinspection PhpUnitTestsInspection * @noinspection UnusedFunctionResultInspection */ - public function test_init_and_init_hooks( bool $logged_in, string $hcaptcha_off_when_logged_in, $whitelisted, bool $hcaptcha_active ) { + public function test_init_and_init_hooks( bool $logged_in, string $hcaptcha_off_when_logged_in, $whitelisted, bool $hcaptcha_active ): void { global $current_user; $hcaptcha = hcaptcha(); @@ -256,7 +256,7 @@ public function test_init_and_init_hooks_on_elementor_pro_edit_page( array $get, array $post, bool $hcaptcha_active - ) { + ): void { global $current_user; add_filter( @@ -368,7 +368,7 @@ public function dp_test_init_and_init_hooks_on_elementor_pro_edit_page(): array * * @throws ReflectionException ReflectionException. */ - public function test_init_and_init_hooks_on_xml_rpc_request() { + public function test_init_and_init_hooks_on_xml_rpc_request(): void { $subject = Mockery::mock( Main::class )->makePartial(); $subject->shouldAllowMockingProtectedMethods()->shouldReceive( 'is_xml_rpc' )->andReturn( true ); @@ -389,7 +389,7 @@ public function test_init_and_init_hooks_on_xml_rpc_request() { /** * Test prefetch_hcaptcha_dns(). */ - public function test_prefetch_hcaptcha_dns() { + public function test_prefetch_hcaptcha_dns(): void { $urls = [ '//s.w.org', ]; @@ -409,7 +409,7 @@ public function test_prefetch_hcaptcha_dns() { * * @return void */ - public function test_csp_headers() { + public function test_csp_headers(): void { $headers = [ 'some_header' => 'some header content', ]; @@ -457,7 +457,7 @@ static function ( $add, $h ) use ( &$headers ) { * @dataProvider dp_test_print_inline_styles * @noinspection CssUnusedSymbol */ - public function test_print_inline_styles( $custom_themes ) { + public function test_print_inline_styles( $custom_themes ): void { $license = 'pro'; $bg = '#f0f0f0'; $config_params = 'on' === $custom_themes @@ -614,7 +614,7 @@ public function dp_test_print_inline_styles(): array { * Test login_head(). * * @noinspection CssUnusedSymbol*/ - public function test_login_head() { + public function test_login_head(): void { FunctionMocker::replace( 'defined', static function ( $constant_name ) { @@ -664,7 +664,7 @@ static function ( $name ) { * @return void * @dataProvider dp_test_get_api_url */ - public function test_get_api_url( string $api_host, string $expected ) { + public function test_get_api_url( string $api_host, string $expected ): void { update_option( 'hcaptcha_settings', [ @@ -699,7 +699,7 @@ public function dp_test_get_api_url(): array { * * @return void */ - public function test_get_api_src() { + public function test_get_api_src(): void { update_option( 'hcaptcha_settings', [ @@ -733,7 +733,7 @@ public function test_get_api_src() { * @return void * @dataProvider dp_test_get_verify_url */ - public function test_get_verify_url( string $backend, string $expected ) { + public function test_get_verify_url( string $backend, string $expected ): void { update_option( 'hcaptcha_settings', [ @@ -772,7 +772,7 @@ public function dp_test_get_verify_url(): array { * @return void * @dataProvider dp_test_get_check_site_config_url */ - public function test_get_check_site_config_url( string $backend, string $expected ) { + public function test_get_check_site_config_url( string $backend, string $expected ): void { update_option( 'hcaptcha_settings', [ @@ -814,7 +814,7 @@ public function dp_test_get_check_site_config_url(): array { * @throws ReflectionException ReflectionException. * @noinspection BadExpressionStatementJS */ - public function test_print_footer_scripts( $compat, $language, $custom_themes, string $expected_script_src ) { + public function test_print_footer_scripts( $compat, $language, $custom_themes, string $expected_script_src ): void { FunctionMocker::replace( 'defined', static function ( $constant_name ) { @@ -984,7 +984,7 @@ function delayedLoad() { * * @return void */ - public function test_print_footer_script_when_blocked_by_filter() { + public function test_print_footer_script_when_blocked_by_filter(): void { add_filter( 'hcap_activate', '__return_true' ); add_filter( 'hcap_print_hcaptcha_scripts', '__return_false' ); @@ -1058,7 +1058,7 @@ public function dp_test_print_footer_scripts(): array { * @dataProvider dp_test_whitelist_ip * @return void */ - public function test_whitelist_ip( $whitelisted_ips, $client_ip, bool $expected ) { + public function test_whitelist_ip( $whitelisted_ips, $client_ip, bool $expected ): void { update_option( 'hcaptcha_settings', [ 'whitelisted_ips' => $whitelisted_ips ] ); $subject = new Main(); @@ -1087,7 +1087,7 @@ public function dp_test_whitelist_ip(): array { /** * Test print_footer_scripts() when form NOT shown. */ - public function test_print_footer_scripts_when_form_NOT_shown() { + public function test_print_footer_scripts_when_form_NOT_shown(): void { self::assertFalse( wp_script_is( 'hcaptcha' ) ); $site_key = 'some key'; @@ -1116,8 +1116,8 @@ public function test_print_footer_scripts_when_form_NOT_shown() { * @dataProvider dp_test_load_modules * @throws ReflectionException ReflectionException. */ - public function test_load_modules( array $module ) { - list( $option_name, $option_value ) = $module[0]; + public function test_load_modules( array $module ): void { + [ $option_name, $option_value ] = $module[0]; update_option( 'hcaptcha_settings', @@ -1668,7 +1668,7 @@ static function ( &$value ) { /** * Test load_textdomain(). */ - public function test_load_textdomain() { + public function test_load_textdomain(): void { $subject = new Main(); $subject->init_hooks(); @@ -1721,7 +1721,7 @@ private function normalize_path( $path ) { * * @param array $component Component. */ - public function check_component_loaded( array $component ) { + public function check_component_loaded( array $component ): void { $intersect = array_intersect( $component, $this->normalize_path( get_included_files() ) ); $included = array_intersect( $component, self::$included_components ); self::assertSame( $included, $intersect ); diff --git a/.tests/php/integration/ACFE/FormTest.php b/.tests/php/integration/ACFE/FormTest.php index 0484b886..143d1900 100644 --- a/.tests/php/integration/ACFE/FormTest.php +++ b/.tests/php/integration/ACFE/FormTest.php @@ -29,7 +29,7 @@ class FormTest extends HCaptchaWPTestCase { /** * Tear down the test. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { unset( $_POST['_acf_post_id'], $_POST[ HCaptcha::HCAPTCHA_WIDGET_ID ] ); wp_dequeue_script( 'hcaptcha' ); @@ -44,7 +44,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test init_hooks(). */ - public function test_init_hooks() { + public function test_init_hooks(): void { $subject = new Form(); self::assertSame( 10, has_action( 'acfe/form/render/before_fields', [ $subject, 'before_fields' ] ) ); @@ -61,7 +61,7 @@ public function test_init_hooks() { * @return void * @throws ReflectionException ReflectionException. */ - public function test_before_fields() { + public function test_before_fields(): void { $id = 5; $subject = new Form(); @@ -82,7 +82,7 @@ public function test_before_fields() { * @dataProvider dp_test_remove_recaptcha_render * @noinspection UnusedFunctionResultInspection */ - public function test_remove_recaptcha_render( array $field, $expected ) { + public function test_remove_recaptcha_render( array $field, $expected ): void { $recaptcha = Mockery::mock( 'acfe_field_recaptcha' ); $recaptcha->shouldReceive( 'render_field' ); @@ -126,7 +126,7 @@ public function dp_test_remove_recaptcha_render(): array { * @return void * @dataProvider dp_test_add_hcaptcha */ - public function test_add_hcaptcha( array $field, string $expected ) { + public function test_add_hcaptcha( array $field, string $expected ): void { $subject = new Form(); hcaptcha()->init_hooks(); @@ -176,7 +176,7 @@ public function dp_test_add_hcaptcha(): array { * @return void * @noinspection UnusedFunctionResultInspection */ - public function test_remove_recaptcha_verify() { + public function test_remove_recaptcha_verify(): void { $value = 'some value'; $field = [ 'type' => 'some' ]; $input = 'some_input_name'; @@ -207,7 +207,7 @@ public function test_remove_recaptcha_verify() { * @dataProvider dp_test_verify * @throws ReflectionException ReflectionException. */ - public function test_verify( bool $result, bool $expected ) { + public function test_verify( bool $result, bool $expected ): void { $valid = ! $expected; $value = 'some hcaptcha response'; $input = 'some_input_name'; @@ -242,7 +242,7 @@ public function dp_test_verify(): array { * * @return void */ - public function test_verify_when_NOT_required() { + public function test_verify_when_NOT_required(): void { $value = 'some hcaptcha response'; $input = 'some_input_name'; $field = [ 'required' => false ]; @@ -259,7 +259,7 @@ public function test_verify_when_NOT_required() { * @return void * @throws ReflectionException ReflectionException. */ - public function test_verify_ajax() { + public function test_verify_ajax(): void { $value = 'some hcaptcha response'; $input = 'some_input_name'; $field = [ 'required' => true ]; @@ -279,7 +279,7 @@ public function test_verify_ajax() { /** * Test enqueue_scripts(). */ - public function test_enqueue_scripts() { + public function test_enqueue_scripts(): void { $field = [ 'type' => 'acfe_recaptcha', 'key' => 'some-key', diff --git a/.tests/php/integration/Admin/Events/EventsTest.php b/.tests/php/integration/Admin/Events/EventsTest.php index 1e334549..ab99bb91 100644 --- a/.tests/php/integration/Admin/Events/EventsTest.php +++ b/.tests/php/integration/Admin/Events/EventsTest.php @@ -29,7 +29,7 @@ class EventsTest extends HCaptchaWPTestCase { * * @return void */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { unset( $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_TRUE_CLIENT_IP'] ); $this->drop_table(); @@ -42,7 +42,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl * * @return void */ - public function test_constructor_and_init_hooks() { + public function test_constructor_and_init_hooks(): void { update_option( 'hcaptcha_settings', [ 'statistics' => [ 'on' ] ] ); hcaptcha()->init_hooks(); @@ -60,7 +60,7 @@ public function test_constructor_and_init_hooks() { * * @return void */ - public function test_save_event() { + public function test_save_event(): void { global $wpdb; $result = 'empty'; @@ -94,7 +94,7 @@ public function test_save_event() { // Query the database to check if the event was saved. // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared - $event = $wpdb->get_row( "SELECT * FROM {$wpdb->prefix}$table_name ORDER BY id DESC LIMIT 1" ); + $event = $wpdb->get_row( "SELECT * FROM $wpdb->prefix$table_name ORDER BY id DESC LIMIT 1" ); // Check that the event data matches the test data. // phpcs:disable WordPress.WP.AlternativeFunctions.json_encode_json_encode @@ -112,7 +112,7 @@ public function test_save_event() { * * @return void */ - public function test_save_event_with_wrong_params() { + public function test_save_event_with_wrong_params(): void { $subject = new Events(); @@ -126,7 +126,7 @@ public function test_save_event_with_wrong_params() { * * @return void */ - public function test_save_event_from_check_config() { + public function test_save_event_from_check_config(): void { $subject = new Events(); @@ -151,7 +151,7 @@ public function test_save_event_from_check_config() { * * @return void */ - public function test_get_events() { + public function test_get_events(): void { $date = wp_date( 'Y-m-d H:i:s' ); $expected = [ @@ -208,7 +208,7 @@ public function test_get_events() { * * @return void */ - public function test_get_forms() { + public function test_get_forms(): void { $date = wp_date( 'Y-m-d H:i:s' ); $expected = [ @@ -261,7 +261,7 @@ public function test_get_forms() { * * @return void */ - public function test_create_table() { + public function test_create_table(): void { global $wpdb; $charset_collate = $wpdb->get_charset_collate(); @@ -294,7 +294,7 @@ public function test_create_table() { * * @return void */ - public function test_get_where_date_gmt() { + public function test_get_where_date_gmt(): void { $dates = [ '2024-05-01', '2024-05-02' ]; $expected = "date_gmt BETWEEN '2024-05-01 00:00:00' AND '2024-05-02 23:59:59'"; @@ -315,12 +315,12 @@ public function test_get_where_date_gmt() { * * @return void */ - private function drop_table() { + private function drop_table(): void { global $wpdb; $table_name = Events::TABLE_NAME; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared - $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}$table_name" ); + $wpdb->query( "DROP TABLE IF EXISTS $wpdb->prefix$table_name" ); } } diff --git a/.tests/php/integration/Admin/NotificationsTest.php b/.tests/php/integration/Admin/NotificationsTest.php index 2fb363d8..d0be5f80 100644 --- a/.tests/php/integration/Admin/NotificationsTest.php +++ b/.tests/php/integration/Admin/NotificationsTest.php @@ -29,7 +29,7 @@ class NotificationsTest extends HCaptchaWPTestCase { * * @return void */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { unset( $_REQUEST['action'], $_REQUEST['nonce'] ); parent::tearDown(); @@ -38,7 +38,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test init() and init_hooks(). */ - public function test_init_and_init_hooks() { + public function test_init_and_init_hooks(): void { $subject = new Notifications(); $subject->init(); @@ -76,7 +76,7 @@ public function test_init_and_init_hooks() { * @dataProvider dp_test_get_notifications * @return void */ - public function test_get_notifications( bool $empty_keys, bool $pro, bool $force ) { + public function test_get_notifications( bool $empty_keys, bool $pro, bool $force ): void { global $current_user; $user_id = 1; @@ -244,7 +244,7 @@ public function dp_test_get_notifications(): array { * @noinspection UnusedFunctionResultInspection * @noinspection HtmlUnknownAttribute */ - public function test_show() { + public function test_show(): void { global $current_user; unset( $current_user ); @@ -463,7 +463,7 @@ class="button button-primary" target="_blank"> * @return void * @noinspection UnusedFunctionResultInspection */ - public function test_show_without_notifications() { + public function test_show_without_notifications(): void { global $current_user; $user_id = 1; @@ -490,7 +490,7 @@ public function test_show_without_notifications() { * * @return void */ - public function test_admin_enqueue_scripts() { + public function test_admin_enqueue_scripts(): void { $params = [ 'ajaxUrl' => 'http://test.test/wp-admin/admin-ajax.php', 'dismissNotificationAction' => Notifications::DISMISS_NOTIFICATION_ACTION, @@ -528,7 +528,7 @@ public function test_admin_enqueue_scripts() { * * @return void */ - public function test_dismiss_notification() { + public function test_dismiss_notification(): void { $user_id = 1; wp_set_current_user( $user_id ); @@ -575,7 +575,7 @@ static function () use ( &$die_arr ) { * * @return void */ - public function test_dismiss_notification_with_bad_ajax_referer() { + public function test_dismiss_notification_with_bad_ajax_referer(): void { $die_arr = []; $expected = [ '', @@ -614,7 +614,7 @@ static function () use ( &$die_arr ) { * * @return void */ - public function test_dismiss_notification_when_user_has_no_caps() { + public function test_dismiss_notification_when_user_has_no_caps(): void { $action = Notifications::DISMISS_NOTIFICATION_ACTION; $nonce = wp_create_nonce( $action ); @@ -659,7 +659,7 @@ static function () use ( &$die_arr ) { * * @return void */ - public function test_dismiss_notification_when_update_error() { + public function test_dismiss_notification_when_update_error(): void { $user_id = 1; wp_set_current_user( $user_id ); @@ -746,7 +746,7 @@ static function () use ( &$die_arr ) { * @return void * @throws ReflectionException ReflectionException. */ - public function test_reset_notifications() { + public function test_reset_notifications(): void { $die_arr = []; $expected = [ '', @@ -852,7 +852,7 @@ static function () use ( &$die_arr ) { * * @return void */ - public function test_make_key_first() { + public function test_make_key_first(): void { $subject = Mockery::mock( Notifications::class )->makePartial(); $subject->shouldAllowMockingProtectedMethods(); diff --git a/.tests/php/integration/AutoVerify/AutoVerifyTest.php b/.tests/php/integration/AutoVerify/AutoVerifyTest.php index fa0ed918..07e1b05d 100644 --- a/.tests/php/integration/AutoVerify/AutoVerifyTest.php +++ b/.tests/php/integration/AutoVerify/AutoVerifyTest.php @@ -26,7 +26,7 @@ class AutoVerifyTest extends HCaptchaWPTestCase { /** * Tear down test. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { unset( $_SERVER['REQUEST_METHOD'], $GLOBALS['current_screen'] ); delete_transient( AutoVerify::TRANSIENT ); @@ -36,7 +36,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test init() and init_hooks(). */ - public function test_init_and_init_hooks() { + public function test_init_and_init_hooks(): void { $subject = new AutoVerify(); $subject->init(); @@ -52,7 +52,7 @@ public function test_init_and_init_hooks() { /** * Test content_filter(). */ - public function test_content_filter() { + public function test_content_filter(): void { $request_uri = $this->get_test_request_uri(); $content = $this->get_test_content(); @@ -70,7 +70,7 @@ public function test_content_filter() { /** * Test widget_block_content_filter(). */ - public function test_widget_block_content_filter() { + public function test_widget_block_content_filter(): void { $wp_widget_block = Mockery::mock( 'WP_Widget_Block' ); $request_uri = $this->get_test_request_uri(); @@ -90,7 +90,7 @@ public function test_widget_block_content_filter() { /** * Test content_filter() with action containing host. */ - public function test_content_filter_with_action() { + public function test_content_filter_with_action(): void { $request_uri = $this->get_test_request_uri(); $content = $this->get_test_content(); $content = str_replace( @@ -113,7 +113,7 @@ public function test_content_filter_with_action() { /** * Test content_filter() when form action cannot be determined. */ - public function test_content_filter_without_form_action() { + public function test_content_filter_without_form_action(): void { $content = $this->get_test_content(); unset( $_SERVER['REQUEST_URI'] ); @@ -128,7 +128,7 @@ public function test_content_filter_without_form_action() { /** * Test content_filter() when no input in form (really?). */ - public function test_content_filter_without_form_inputs() { + public function test_content_filter_without_form_inputs(): void { $request_uri = wp_parse_url( $this->get_test_request_uri(), PHP_URL_PATH ); $content = $this->get_test_content(); $content = preg_replace( '##', '', $content ); @@ -152,7 +152,7 @@ public function test_content_filter_without_form_inputs() { /** * Test content_filter() when no data-auto in form (really?). */ - public function test_content_filter_without_form_data_auto() { + public function test_content_filter_without_form_data_auto(): void { $request_uri = $this->get_test_request_uri(); $content = $this->get_test_content(); $content = preg_replace( '#data-auto=".*?">#', '', $content ); @@ -179,7 +179,7 @@ public function test_content_filter_without_form_data_auto() { /** * Test content_filter() in admin. */ - public function test_content_filter_in_admin() { + public function test_content_filter_in_admin(): void { set_current_screen( 'some-screen' ); $content = $this->get_test_content(); @@ -194,7 +194,7 @@ public function test_content_filter_in_admin() { /** * Test content_filter() in ajax. */ - public function test_content_filter_in_ajax() { + public function test_content_filter_in_ajax(): void { $content = $this->get_test_content(); $subject = new AutoVerify(); @@ -214,7 +214,7 @@ static function () { /** * Test verify_form() when not POST request. */ - public function test_verify_form_when_not_post() { + public function test_verify_form_when_not_post(): void { $subject = new AutoVerify(); $subject->verify_form(); @@ -225,7 +225,7 @@ public function test_verify_form_when_not_post() { /** * Test verify_form() when no $_SERVER['REQUEST_URI'] defined. */ - public function test_verify_form_when_no_request_uri() { + public function test_verify_form_when_no_request_uri(): void { $_SERVER['REQUEST_METHOD'] = 'POST'; unset( $_SERVER['REQUEST_URI'] ); @@ -237,7 +237,7 @@ public function test_verify_form_when_no_request_uri() { /** * Test verify_form() when no forms are registered. */ - public function test_verify_form_when_no_forms_are_registered() { + public function test_verify_form_when_no_forms_are_registered(): void { $request_uri = $this->get_test_request_uri(); $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -250,7 +250,7 @@ public function test_verify_form_when_no_forms_are_registered() { /** * Test verify_form() when forms on another uri are registered. */ - public function test_verify_form_when_forms_on_another_uri_are_registered() { + public function test_verify_form_when_forms_on_another_uri_are_registered(): void { $request_uri = $this->get_test_request_uri(); $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -267,9 +267,9 @@ public function test_verify_form_when_forms_on_another_uri_are_registered() { } /** - * Test verify_form() when another forms on the same uri are registered. + * Test verify_form() when other forms on the same uri are registered. */ - public function test_verify_form_when_another_forms_on_the_same_uri_are_registered() { + public function test_verify_form_when_other_forms_on_the_same_uri_are_registered(): void { $request_uri = $this->get_test_request_uri(); $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -290,7 +290,7 @@ public function test_verify_form_when_another_forms_on_the_same_uri_are_register * * @noinspection PhpUnusedParameterInspection */ - public function test_verify_form_when_no_success() { + public function test_verify_form_when_no_success(): void { $request_uri = $this->get_test_request_uri(); $_SERVER['REQUEST_METHOD'] = 'POST'; @@ -330,7 +330,7 @@ static function ( $name ) use ( &$die_arr ) { /** * Test verify_form() when verify is successful. */ - public function test_verify_form_when_success() { + public function test_verify_form_when_success(): void { $request_uri = $this->get_test_request_uri(); $hcaptcha_response = 'some response'; $expected = [ @@ -360,7 +360,7 @@ public function test_verify_form_when_success() { /** * Test verify_form() in admin. */ - public function test_verify_form_in_admin() { + public function test_verify_form_in_admin(): void { set_current_screen( 'some-screen' ); $subject = new AutoVerify(); @@ -370,7 +370,7 @@ public function test_verify_form_in_admin() { /** * Test verify_form() in ajax. */ - public function test_verify_form_in_ajax() { + public function test_verify_form_in_ajax(): void { add_filter( 'wp_doing_ajax', static function () { @@ -385,7 +385,7 @@ static function () { /** * Test verify_form() in rest, case 3 and 4. */ - public function test_verify_form_in_rest_case_3_and_4() { + public function test_verify_form_in_rest_case_3_and_4(): void { $old_wp_rewrite = $GLOBALS['wp_rewrite']; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited diff --git a/.tests/php/integration/Avada/FormTest.php b/.tests/php/integration/Avada/FormTest.php index ea335ffa..b7947231 100644 --- a/.tests/php/integration/Avada/FormTest.php +++ b/.tests/php/integration/Avada/FormTest.php @@ -27,7 +27,7 @@ class FormTest extends HCaptchaWPTestCase { * * @return void */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { unset( $_POST['formData'], $_POST['hcaptcha-widget-id'] ); parent::tearDown(); @@ -38,7 +38,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl * * @return void */ - public function test_init_hooks() { + public function test_init_hooks(): void { $subject = new Form(); self::assertSame( 10, has_action( 'fusion_form_after_open', [ $subject, 'form_after_open' ] ) ); @@ -51,7 +51,7 @@ public function test_init_hooks() { * * @return void */ - public function test_add_hcaptcha() { + public function test_add_hcaptcha(): void { $form_id = 5; $args = [ 'id' => @@ -79,7 +79,7 @@ public function test_add_hcaptcha() { * @return void * @noinspection PhpConditionAlreadyCheckedInspection */ - public function test_verify() { + public function test_verify(): void { $demo_mode = true; $hcaptcha_response = 'some_response'; $form_data = "h-captcha-response=$hcaptcha_response"; @@ -97,8 +97,9 @@ public function test_verify() { * Test verify() when not verified. * * @return void + * @noinspection PhpUnusedParameterInspection */ - public function test_verify_not_verified() { + public function test_verify_not_verified(): void { $hcaptcha_response = 'some_response'; $die_arr = []; $expected = [ diff --git a/.tests/php/integration/BBPress/NewTopicTest.php b/.tests/php/integration/BBPress/NewTopicTest.php index dc75fcc1..e5d8e240 100644 --- a/.tests/php/integration/BBPress/NewTopicTest.php +++ b/.tests/php/integration/BBPress/NewTopicTest.php @@ -35,7 +35,7 @@ class NewTopicTest extends HCaptchaPluginWPTestCase { * * @noinspection PhpUndefinedFunctionInspection */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { // phpcs:ignore WordPress.Security.NonceVerification.Missing unset( $_POST ); bbpress()->errors = new WP_Error(); @@ -46,7 +46,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test add_captcha(). */ - public function test_add_captcha() { + public function test_add_captcha(): void { $args = [ 'action' => 'hcaptcha_bbp_new_topic', 'name' => 'hcaptcha_bbp_new_topic_nonce', @@ -72,7 +72,7 @@ public function test_add_captcha() { * * @noinspection PhpUndefinedFunctionInspection */ - public function test_verify() { + public function test_verify(): void { $this->prepare_hcaptcha_get_verify_message( 'hcaptcha_bbp_new_topic_nonce', 'hcaptcha_bbp_new_topic' ); $expected = new WP_Error(); @@ -88,7 +88,7 @@ public function test_verify() { * * @noinspection PhpUndefinedFunctionInspection */ - public function test_verify_not_verified() { + public function test_verify_not_verified(): void { $expected = new WP_Error( 'hcap_error', 'Please complete the hCaptcha.' ); $subject = new NewTopic(); diff --git a/.tests/php/integration/BBPress/ReplyTest.php b/.tests/php/integration/BBPress/ReplyTest.php index 83ce7a67..12419fde 100644 --- a/.tests/php/integration/BBPress/ReplyTest.php +++ b/.tests/php/integration/BBPress/ReplyTest.php @@ -35,7 +35,7 @@ class ReplyTest extends HCaptchaPluginWPTestCase { * * @noinspection PhpUndefinedFunctionInspection */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { // phpcs:ignore WordPress.Security.NonceVerification.Missing unset( $_POST ); bbpress()->errors = new WP_Error(); @@ -46,7 +46,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test add_captcha(). */ - public function test_add_captcha() { + public function test_add_captcha(): void { $args = [ 'action' => 'hcaptcha_bbp_reply', 'name' => 'hcaptcha_bbp_reply_nonce', @@ -71,7 +71,7 @@ public function test_add_captcha() { * * @noinspection PhpUndefinedFunctionInspection */ - public function test_verify() { + public function test_verify(): void { $this->prepare_hcaptcha_get_verify_message( 'hcaptcha_bbp_reply_nonce', 'hcaptcha_bbp_reply' ); $expected = new WP_Error(); @@ -87,7 +87,7 @@ public function test_verify() { * * @noinspection PhpUndefinedFunctionInspection */ - public function test_verify_not_verified() { + public function test_verify_not_verified(): void { $expected = new WP_Error( 'hcap_error', 'Please complete the hCaptcha.' ); $subject = new Reply(); diff --git a/.tests/php/integration/BuddyPress/CreateGroupTest.php b/.tests/php/integration/BuddyPress/CreateGroupTest.php index 46451fe4..774d0d18 100644 --- a/.tests/php/integration/BuddyPress/CreateGroupTest.php +++ b/.tests/php/integration/BuddyPress/CreateGroupTest.php @@ -33,7 +33,7 @@ class CreateGroupTest extends HCaptchaPluginWPTestCase { /** * Tear down the test. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { global $bp; unset( $bp->signup ); @@ -44,7 +44,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test add_captcha(). */ - public function test_hcap_bp_group_form() { + public function test_hcap_bp_group_form(): void { $args = [ 'action' => 'hcaptcha_bp_create_group', 'name' => 'hcaptcha_bp_create_group_nonce', @@ -70,7 +70,7 @@ public function test_hcap_bp_group_form() { /** * Test verify(). */ - public function test_verify() { + public function test_verify(): void { FunctionMocker::replace( 'bp_is_group_creation_step', static function ( $step_slug ) { @@ -88,7 +88,7 @@ static function ( $step_slug ) { /** * Test verify() when not in step. */ - public function test_verify_not_in_step() { + public function test_verify_not_in_step(): void { FunctionMocker::replace( 'bp_is_group_creation_step', false ); $subject = new CreateGroup(); @@ -102,7 +102,7 @@ public function test_verify_not_in_step() { * @noinspection PhpUnusedParameterInspection * @noinspection PhpUndefinedFunctionInspection */ - public function test_verify_not_verified() { + public function test_verify_not_verified(): void { FunctionMocker::replace( 'bp_is_group_creation_step', static function ( $step_slug ) { @@ -142,8 +142,9 @@ static function ( $location, $status ) { * Test print_inline_styles(). * * @return void + * @noinspection CssUnusedSymbol */ - public function test_print_inline_styles() { + public function test_print_inline_styles(): void { FunctionMocker::replace( 'defined', static function ( $constant_name ) { diff --git a/.tests/php/integration/BuddyPress/RegisterTest.php b/.tests/php/integration/BuddyPress/RegisterTest.php index 9744e094..873618aa 100644 --- a/.tests/php/integration/BuddyPress/RegisterTest.php +++ b/.tests/php/integration/BuddyPress/RegisterTest.php @@ -32,7 +32,7 @@ class RegisterTest extends HCaptchaPluginWPTestCase { /** * Tear down the test. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { global $bp; unset( $bp->signup ); @@ -43,7 +43,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test add_captcha(). */ - public function test_add_captcha() { + public function test_add_captcha(): void { $args = [ 'action' => 'hcaptcha_bp_register', 'name' => 'hcaptcha_bp_register_nonce', @@ -66,7 +66,7 @@ public function test_add_captcha() { /** * Test add_captcha() with error. */ - public function test_register_error() { + public function test_register_error(): void { global $bp; $args = [ @@ -102,7 +102,7 @@ public function test_register_error() { /** * Test verify(). */ - public function test_verify() { + public function test_verify(): void { $this->prepare_hcaptcha_get_verify_message( 'hcaptcha_bp_register_nonce', 'hcaptcha_bp_register' ); $subject = new Register(); @@ -113,7 +113,7 @@ public function test_verify() { /** * Test verify() not verified. */ - public function test_verify_not_verified() { + public function test_verify_not_verified(): void { global $bp; $bp->signup = (object) [ diff --git a/.tests/php/integration/CF7/AdminTest.php b/.tests/php/integration/CF7/AdminTest.php index 2ba5cbe2..7c435dac 100644 --- a/.tests/php/integration/CF7/AdminTest.php +++ b/.tests/php/integration/CF7/AdminTest.php @@ -37,7 +37,7 @@ class AdminTest extends HCaptchaPluginWPTestCase { /** * Tear down the test. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { unset( $GLOBALS['current_screen'], $_GET['post'], $_GET['page'] ); parent::tearDown(); @@ -53,7 +53,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl * * @dataProvider dp_test_init_hooks */ - public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_admin, bool $expected ) { + public function test_init_hooks( bool $mode_auto, bool $mode_embed, bool $is_admin, bool $expected ): void { $cf7_status = array_filter( [ $mode_auto ? 'form' : '', $mode_embed ? 'embed' : '' ] ); if ( $is_admin ) { @@ -139,7 +139,7 @@ public function dp_test_init_hooks(): array { * * @return void */ - public function test_toplevel_page_wpcf7() { + public function test_toplevel_page_wpcf7(): void { $form = <<

Edit Contact Form

@@ -227,8 +227,9 @@ public function test_toplevel_page_wpcf7() { * Test add_tag_generator_hcaptcha(). * * @return void + * @noinspection PhpUndefinedConstantInspection */ - public function test_add_tag_generator_hcaptcha() { + public function test_add_tag_generator_hcaptcha(): void { require_once WPCF7_PLUGIN_DIR . '/admin/includes/tag-generator.php'; $tag_generator = WPCF7_TagGenerator::get_instance(); @@ -280,7 +281,7 @@ public function test_add_tag_generator_hcaptcha() { * * @return void */ - public function test_tag_generator_hcaptcha() { + public function test_tag_generator_hcaptcha(): void { $args = [ 'id' => 'cf7-hcaptcha', 'title' => 'hCaptcha', @@ -348,8 +349,9 @@ public function test_tag_generator_hcaptcha() { * Test enqueue_admin_scripts_before_cf7() and enqueue_admin_scripts_after_cf7(). * * @noinspection PhpConditionAlreadyCheckedInspection + * @noinspection PhpUndefinedConstantInspection */ - public function test_enqueue_admin_scripts() { + public function test_enqueue_admin_scripts(): void { global $wp_scripts; set_current_screen( 'some' ); diff --git a/.tests/php/integration/CF7/CF7Test.php b/.tests/php/integration/CF7/CF7Test.php index 6290eb16..d380f1ad 100644 --- a/.tests/php/integration/CF7/CF7Test.php +++ b/.tests/php/integration/CF7/CF7Test.php @@ -39,7 +39,7 @@ class CF7Test extends HCaptchaPluginWPTestCase { /** * Tear down the test. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { unset( $_REQUEST['_wpnonce'], $_POST['_wpcf7'], $_SERVER['REQUEST_URI'] ); hcaptcha()->form_shown = false; diff --git a/.tests/php/integration/DelayedScript/DelayedScriptTest.php b/.tests/php/integration/DelayedScript/DelayedScriptTest.php index 081a1352..414faa4a 100644 --- a/.tests/php/integration/DelayedScript/DelayedScriptTest.php +++ b/.tests/php/integration/DelayedScript/DelayedScriptTest.php @@ -25,7 +25,7 @@ class DelayedScriptTest extends HCaptchaWPTestCase { * @noinspection JSUnresolvedReference * @noinspection JSUnusedLocalSymbols */ - public function test_create() { + public function test_create(): void { FunctionMocker::replace( 'defined', static function ( $constant_name ) { @@ -108,7 +108,7 @@ function delayedLoad() { * * @noinspection BadExpressionStatementJS */ - public function test_launch() { + public function test_launch(): void { FunctionMocker::replace( 'defined', static function ( $constant_name ) { diff --git a/.tests/php/integration/Divi/CommentTest.php b/.tests/php/integration/Divi/CommentTest.php index 9aa398b3..757a3efd 100644 --- a/.tests/php/integration/Divi/CommentTest.php +++ b/.tests/php/integration/Divi/CommentTest.php @@ -21,7 +21,7 @@ class CommentTest extends HCaptchaWPTestCase { /** * Test constructor and init_hooks(). */ - public function test_constructor_and_init_hooks() { + public function test_constructor_and_init_hooks(): void { $subject = new Comment(); self::assertSame( 10, has_filter( Comment::TAG . '_shortcode_output', [ $subject, 'add_captcha' ] ) ); @@ -30,7 +30,7 @@ public function test_constructor_and_init_hooks() { /** * Test add_captcha(). */ - public function test_add_captcha() { + public function test_add_captcha(): void { $form_id = '3075'; $output = << @@ -61,7 +61,7 @@ public function test_add_captcha() { /** * Test add_captcha() when output is not a string. */ - public function test_add_captcha_when_output_is_not_a_string() { + public function test_add_captcha_when_output_is_not_a_string(): void { $output = [ 'some string' ]; $module_slug = 'et_pb_comments'; @@ -73,7 +73,7 @@ public function test_add_captcha_when_output_is_not_a_string() { /** * Test add_captcha() when output has hCaptcha. */ - public function test_add_captcha_when_output_has_hcaptcha() { + public function test_add_captcha_when_output_has_hcaptcha(): void { $output = 'some output with h-captcha attr'; $module_slug = 'et_pb_comments'; @@ -85,7 +85,7 @@ public function test_add_captcha_when_output_has_hcaptcha() { /** * Test add_captcha() in frontend builder. */ - public function test_add_captcha_in_frontend_builder() { + public function test_add_captcha_in_frontend_builder(): void { $output = 'some string'; $module_slug = 'et_pb_comments'; diff --git a/.tests/php/integration/Divi/ContactTest.php b/.tests/php/integration/Divi/ContactTest.php index 1c043075..a087d0bc 100644 --- a/.tests/php/integration/Divi/ContactTest.php +++ b/.tests/php/integration/Divi/ContactTest.php @@ -42,11 +42,8 @@ class ContactTest extends HCaptchaWPTestCase { /** * Tear down test. - * - * @noinspection PhpLanguageLevelInspection - * @noinspection PhpUndefinedClassInspection */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { // phpcs:disable WordPress.Security.NonceVerification.Missing unset( $_POST[ $this->cf_nonce_field ], @@ -60,7 +57,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test constructor and init_hooks(). */ - public function test_constructor_and_init_hooks() { + public function test_constructor_and_init_hooks(): void { $subject = new Contact(); self::assertSame( @@ -87,7 +84,7 @@ public function test_constructor_and_init_hooks() { * * @throws ReflectionException ReflectionException. */ - public function test_add_captcha() { + public function test_add_captcha(): void { FunctionMocker::replace( 'et_core_is_fb_enabled', false ); $output = ' @@ -196,7 +193,7 @@ public function test_add_captcha() { * * @throws ReflectionException ReflectionException. */ - public function test_add_captcha_in_frontend_builder() { + public function test_add_captcha_in_frontend_builder(): void { FunctionMocker::replace( 'et_core_is_fb_enabled', true ); $output = [ 'some array' ]; @@ -214,7 +211,7 @@ public function test_add_captcha_in_frontend_builder() { * * @throws ReflectionException ReflectionException. */ - public function test_verify() { + public function test_verify(): void { $return = 'some html'; $tag = 'et_pb_contact_form'; @@ -277,7 +274,7 @@ function ( $type, $var_name, $filter ) use ( $nonce, $current_form_fields ) { * * @throws ReflectionException ReflectionException. */ - public function test_verify_not_verified() { + public function test_verify_not_verified(): void { $return = 'some html'; $tag = 'et_pb_contact_form'; @@ -338,7 +335,7 @@ function ( $type, $var_name, $filter ) use ( $nonce, $current_form_fields ) { /** * Test verify() with wrong tag. */ - public function test_verify_wrong_tag() { + public function test_verify_wrong_tag(): void { $return = 'some html'; $tag = 'wrong tag'; @@ -357,7 +354,7 @@ public function test_verify_wrong_tag() { * @throws ReflectionException ReflectionException. * @noinspection PhpMissingParamTypeInspection */ - public function test_shortcode_attributes( $captcha, string $own_captcha ) { + public function test_shortcode_attributes( $captcha, string $own_captcha ): void { $props = [ 'foo' => 'bar' ]; $attrs = []; $slug = 'et_pb_contact_form'; @@ -401,7 +398,7 @@ public function dp_test_shortcode_attributes(): array { * * @throws ReflectionException ReflectionException. */ - public function test_shortcode_attributes_with_wrong_slug() { + public function test_shortcode_attributes_with_wrong_slug(): void { $props = [ 'foo' => 'bar', 'captcha' => 'some', @@ -423,7 +420,7 @@ public function test_shortcode_attributes_with_wrong_slug() { /** * Test enqueue_scripts(). */ - public function test_enqueue_scripts() { + public function test_enqueue_scripts(): void { $subject = new Contact(); self::assertFalse( wp_script_is( 'hcaptcha-divi' ) ); diff --git a/.tests/php/integration/Divi/EmailOptinTest.php b/.tests/php/integration/Divi/EmailOptinTest.php index 49b40247..21019910 100644 --- a/.tests/php/integration/Divi/EmailOptinTest.php +++ b/.tests/php/integration/Divi/EmailOptinTest.php @@ -26,7 +26,7 @@ class EmailOptinTest extends HCaptchaWPTestCase { /** * Tear down test. */ - public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound + public function tearDown(): void { wp_dequeue_script( EmailOptin::HANDLE ); parent::tearDown(); @@ -35,7 +35,7 @@ public function tearDown(): void { // phpcs:ignore PHPCompatibility.FunctionDecl /** * Test constructor and init_hooks(). */ - public function test_constructor_and_init_hooks() { + public function test_constructor_and_init_hooks(): void { $subject = new EmailOptin(); self::assertSame( 10, has_filter( 'et_pb_signup_form_field_html_submit_button', [ $subject, 'add_captcha' ] ) ); @@ -47,7 +47,7 @@ public function test_constructor_and_init_hooks() { /** * Test add_captcha(). */ - public function test_add_captcha() { + public function test_add_captcha(): void { $wrap = '

'; $html = << @@ -79,7 +79,7 @@ public function test_add_captcha() { * * @return void */ - public function test_verify() { + public function test_verify(): void { $this->prepare_hcaptcha_get_verify_message_html( EmailOptin::NONCE, EmailOptin::ACTION ); $subject = new EmailOptin(); @@ -92,7 +92,7 @@ public function test_verify() { * * @return void */ - public function test_verify_not_verified() { + public function test_verify_not_verified(): void { $error_message = 'hCaptcha error: The hCaptcha is invalid.'; $et_core_die = FunctionMocker::replace( 'et_core_die' ); @@ -111,7 +111,7 @@ public function test_verify_not_verified() { * * @return void */ - public function test_enqueue_scripts() { + public function test_enqueue_scripts(): void { hcaptcha()->form_shown = true; self::assertFalse( wp_script_is( EmailOptin::HANDLE ) ); @@ -128,7 +128,7 @@ public function test_enqueue_scripts() { * * @return void */ - public function test_enqueue_scripts_when_form_was_not_shown() { + public function test_enqueue_scripts_when_form_was_not_shown(): void { self::assertFalse( wp_script_is( EmailOptin::HANDLE ) ); $subject = new EmailOptin(); diff --git a/.tests/php/integration/Divi/LoginTest.php b/.tests/php/integration/Divi/LoginTest.php index 73e80b99..5886ad16 100644 --- a/.tests/php/integration/Divi/LoginTest.php +++ b/.tests/php/integration/Divi/LoginTest.php @@ -21,7 +21,7 @@ class LoginTest extends HCaptchaWPTestCase { /** * Test constructor and init_hooks(). */ - public function test_constructor_and_init_hooks() { + public function test_constructor_and_init_hooks(): void { $subject = new Login(); self::assertSame( 10, has_filter( Login::TAG . '_shortcode_output', [ $subject, 'add_divi_captcha' ] ) ); @@ -30,7 +30,7 @@ public function test_constructor_and_init_hooks() { /** * Test add_divi_captcha(). */ - public function test_add_divi_captcha() { + public function test_add_divi_captcha(): void { FunctionMocker::replace( 'et_core_is_fb_enabled', false ); $output = '