From 155cf2d58319f413a0671dea964fd2746547f3e8 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 24 Feb 2026 15:28:01 -0400 Subject: [PATCH 1/4] Update rector config to actually fix issues in tests --- classes/models/FrmAntiSpam.php | 2 +- rector.php | 22 ++++++++++++++++++- stubs.php | 6 +++++ .../test_FrmApplicationsController.php | 4 ++-- tests/phpunit/database/test_FrmMigrate.php | 8 +++---- tests/phpunit/emails/test_FrmEmail.php | 14 ++++++------ .../emails/test_FrmEmailSummaryHelper.php | 8 +++---- tests/phpunit/entries/test_FrmEntry.php | 6 ++--- .../phpunit/entries/test_FrmEntryValidate.php | 12 +++++----- tests/phpunit/fields/test_FrmField.php | 2 +- .../phpunit/fields/test_FrmFieldFormHtml.php | 4 ++-- .../fields/test_FrmFieldGridHelper.php.php | 6 ++--- tests/phpunit/fields/test_FrmFieldName.php | 6 ++--- .../phpunit/fields/test_FrmFieldValidate.php | 18 +++++++-------- .../test_FrmFormTemplatesController.php | 18 +++++++-------- tests/phpunit/forms/test_FrmForm.php | 2 +- .../phpunit/forms/test_FrmFormsController.php | 8 +++---- .../phpunit/forms/test_FrmOnSubmitAction.php | 2 +- tests/phpunit/misc/test_FrmAddon.php | 5 ++--- tests/phpunit/misc/test_FrmAntiSpam.php | 6 ++--- tests/phpunit/misc/test_FrmAppController.php | 8 +++---- tests/phpunit/misc/test_FrmAppHelper.php | 8 +++---- .../phpunit/misc/test_FrmCSVExportHelper.php | 10 ++++----- .../phpunit/misc/test_FrmHooksController.php | 2 +- tests/phpunit/misc/test_FrmMisc.php | 8 +++---- .../misc/test_FrmSimpleBlocksController.php | 4 ++-- .../misc/test_FrmSpamCheckDenylist.php | 14 +++++------- tests/phpunit/styles/test_FrmStyleApi.php | 4 ++-- .../styles/test_FrmStylesController.php | 4 ++-- tests/phpunit/styles/test_FrmStylesHelper.php | 6 ++--- tests/phpunit/xml/test_FrmXMLHelper.php | 2 +- 31 files changed, 126 insertions(+), 103 deletions(-) diff --git a/classes/models/FrmAntiSpam.php b/classes/models/FrmAntiSpam.php index 55b00021ba..4615a7b728 100644 --- a/classes/models/FrmAntiSpam.php +++ b/classes/models/FrmAntiSpam.php @@ -108,7 +108,7 @@ private function get_valid_tokens() { // Two days ago. 2 * DAY_IN_SECONDS, // One day ago. - 1 * DAY_IN_SECONDS, + DAY_IN_SECONDS, ) ); diff --git a/rector.php b/rector.php index a9751dc6ee..2617eb97bb 100644 --- a/rector.php +++ b/rector.php @@ -67,9 +67,23 @@ use Rector\TypeDeclarationDocblocks\Rector\ClassMethod\AddParamArrayDocblockFromDimFetchAccessRector; use Rector\TypeDeclarationDocblocks\Rector\ClassMethod\DocblockReturnArrayFromDirectArrayInstanceRector; -define( 'ABSPATH', '' ); +// PHP Unit +use Rector\PHPUnit\CodeQuality\Rector\StmtsAwareInterface\DeclareStrictTypesTestsRector; +use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector; +use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; +use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; return RectorConfig::configure() + ->withBootstrapFiles( + array( + __DIR__ . '/stubs.php', + ) + ) + ->withAutoloadPaths( + array( + __DIR__ . '/tests/phpunit/base', + ) + ) ->withPaths( array( __DIR__ . '/classes', @@ -215,5 +229,11 @@ AddParamArrayDocblockFromDimFetchAccessRector::class, DocblockReturnArrayFromDirectArrayInstanceRector::class, AddReturnDocblockForDimFetchArrayFromAssignsRector::class, + + // PHP Unit + DeclareStrictTypesTestsRector::class, + FinalizeTestCaseClassRector::class, + PrivatizeFinalClassPropertyRector::class, + StringClassNameToClassConstantRector::class, ) ); diff --git a/stubs.php b/stubs.php index b590d17097..f39b43a35d 100644 --- a/stubs.php +++ b/stubs.php @@ -512,6 +512,12 @@ class FrmProFormsController{ public static function enqueue_pro_web_components_script(){ } } + + class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase { + } + + class WP_UnitTestCase extends WP_UnitTestCase_Base { + } } namespace Elementor { diff --git a/tests/phpunit/applications/test_FrmApplicationsController.php b/tests/phpunit/applications/test_FrmApplicationsController.php index 2b4fdc41dd..942d85f90a 100644 --- a/tests/phpunit/applications/test_FrmApplicationsController.php +++ b/tests/phpunit/applications/test_FrmApplicationsController.php @@ -12,7 +12,7 @@ public function test_landing_page() { ob_start(); FrmApplicationsController::landing_page(); $html = ob_get_clean(); - $this->assertStringContainsString( 'id="frm_applications_container"', $html ); + $this->assertStringContainsString( 'id="frm_applications_container"', (string) $html ); } /** @@ -48,6 +48,6 @@ public function test_render_applications_header() { $title = 'Applications'; FrmApplicationsController::render_applications_header( $title, 'index' ); $html = ob_get_clean(); - $this->assertStringContainsString( $title, $html ); + $this->assertStringContainsString( $title, (string) $html ); } } diff --git a/tests/phpunit/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index 8cb892921b..d4eced5e4e 100644 --- a/tests/phpunit/database/test_FrmMigrate.php +++ b/tests/phpunit/database/test_FrmMigrate.php @@ -30,14 +30,14 @@ public function test_maybe_create_contact_form() { // Check for auto contact form. $form = FrmForm::getOne( 'contact-form' ); - $this->assertNotEmpty( $form ); + $this->assertInstanceOf( \stdClass::class, $form ); $this->assertSame( 'contact-form', $form->form_key ); // Make sure the form isn't recreated after delete FrmForm::destroy( 'contact-form' ); $frmdb->upgrade(); $form = FrmForm::getOne( 'contact-form' ); - $this->assertEmpty( $form ); + $this->assertNotInstanceOf( \stdClass::class, $form ); } /** @@ -361,12 +361,12 @@ public function test_migrate_from_12_to_current() { $form = FrmForm::getOne( 'contact-db12-copy' ); $form_actions = FrmFormAction::get_action_for_form( $form->id, 'email' ); - $this->assertTrue( ! isset( $form->options['notification'] ), 'The migrated notification settings are not cleared from form.' ); + $this->assertArrayNotHasKey( 'notification', $form->options, 'The migrated notification settings are not cleared from form.' ); $this->assertCount( 1, $form_actions, 'Old form settings are not converted to email action.' ); foreach ( $form_actions as $action ) { - $this->assertStringContainsString( 'emailto@test.com', $action->post_content['email_to'] ); + $this->assertStringContainsString( 'emailto@test.com', (string) $action->post_content['email_to'] ); } } diff --git a/tests/phpunit/emails/test_FrmEmail.php b/tests/phpunit/emails/test_FrmEmail.php index 4e6d2cc0b6..165602f1b1 100644 --- a/tests/phpunit/emails/test_FrmEmail.php +++ b/tests/phpunit/emails/test_FrmEmail.php @@ -476,8 +476,8 @@ protected function check_recipients( $expected, $mock_email, $cc_status = 'yes_c * @param array $mock_email */ protected function check_senders( $expected, $mock_email ) { - $this->assertStringContainsString( 'From: ' . $expected['from'], $mock_email['header'], 'From does not match expected.' ); - $this->assertStringContainsString( 'Reply-To: ' . $expected['reply_to'], $mock_email['header'], 'Reply-to does not match expected.' ); + $this->assertStringContainsString( 'From: ' . $expected['from'], (string) $mock_email['header'], 'From does not match expected.' ); + $this->assertStringContainsString( 'Reply-To: ' . $expected['reply_to'], (string) $mock_email['header'], 'Reply-to does not match expected.' ); } /** @@ -507,21 +507,21 @@ protected function check_message_body( $expected, $mock_email ) { * @param array $mock_email */ protected function check_content_type( $expected, $mock_email ) { - $this->assertStringContainsString( $expected['content_type'], $mock_email['header'], 'Content type does not match expected.' ); + $this->assertStringContainsString( $expected['content_type'], (string) $mock_email['header'], 'Content type does not match expected.' ); } /** * @param array $mock_email */ protected function check_no_cc_included( $mock_email ) { - $this->assertStringNotContainsString( 'Cc:', $mock_email['header'], 'CC is included when it should not be.' ); + $this->assertStringNotContainsString( 'Cc:', (string) $mock_email['header'], 'CC is included when it should not be.' ); } /** * @param array $mock_email */ protected function check_no_bcc_included( $mock_email ) { - $this->assertStringNotContainsString( 'Bcc:', $mock_email['header'], 'BCC is included when it should not be.' ); + $this->assertStringNotContainsString( 'Bcc:', (string) $mock_email['header'], 'BCC is included when it should not be.' ); } /** @@ -723,9 +723,9 @@ public function test_message_user_info() { $actual = $this->get_private_property( $email, 'message' ); if ( $setting['compare'] === 'Contains' ) { - $this->assertStringContainsString( 'Referrer:', $actual ); + $this->assertStringContainsString( 'Referrer:', (string) $actual ); } else { - $this->assertStringNotContainsString( 'Referrer:', $actual ); + $this->assertStringNotContainsString( 'Referrer:', (string) $actual ); } } } diff --git a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php index 3a5721fc32..210d47672b 100644 --- a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php +++ b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php @@ -13,9 +13,9 @@ public function test_get_options() { array( 'FrmEmailSummaryHelper', 'get_options' ) ); - $this->assertTrue( isset( $options['last_monthly'] ) ); - $this->assertTrue( isset( $options['last_yearly'] ) ); - $this->assertTrue( isset( $options['renewal_date'] ) ); + $this->assertArrayHasKey('last_monthly', $options); + $this->assertArrayHasKey('last_yearly', $options); + $this->assertArrayHasKey('renewal_date', $options); } public function test_get_date_obj() { @@ -24,7 +24,7 @@ public function test_get_date_obj() { array( '2023-08-13' ) ); - $this->assertTrue( $date instanceof DateTime ); + $this->assertInstanceOf(\DateTime::class, $date); $this->assertSame( '2023-08-13', $date->format( 'Y-m-d' ) ); $this->assertFalse( diff --git a/tests/phpunit/entries/test_FrmEntry.php b/tests/phpunit/entries/test_FrmEntry.php index 30a02388cc..ae13c35dcc 100644 --- a/tests/phpunit/entries/test_FrmEntry.php +++ b/tests/phpunit/entries/test_FrmEntry.php @@ -62,14 +62,14 @@ public function test_getAll() { $first_item = reset( $items ); $this->assertIsObject( $first_item ); - $this->assertTrue( empty( $first_item->metas ), 'Entries should not include metas unless $meta = true is set.' ); + $this->assertEmpty( $first_item->metas, 'Entries should not include metas unless $meta = true is set.' ); // Test with $meta = true. $items = FrmEntry::getAll( array( 'it.form_id' => $form->id ), '', '', true, false ); $first_item = reset( $items ); $this->assertIsObject( $first_item ); - $this->assertTrue( ! empty( $first_item->metas ) ); + $this->assertNotEmpty( $first_item->metas ); $this->assertIsArray( $first_item->metas ); $email_field = FrmField::getOne( 'contact-email' ); @@ -97,7 +97,7 @@ public function test_getAll() { $item = reset( $items ); $this->assertIsObject( $item ); - $this->assertTrue( ! empty( $item->metas ) ); + $this->assertNotEmpty( $item->metas ); $this->assertIsArray( $item->metas ); $this->assertArrayHasKey( $checkbox_field_id, $item->metas ); diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php index a5a315675b..310c8b5c17 100644 --- a/tests/phpunit/entries/test_FrmEntryValidate.php +++ b/tests/phpunit/entries/test_FrmEntryValidate.php @@ -56,8 +56,8 @@ public function test_get_spam_check_user_info() { wp_set_current_user( null ); $this->run_private_method( array( 'FrmEntryValidate', 'prepare_values_for_spam_check' ), array( &$values ) ); $check = $this->get_spam_check_user_info( $values ); - $this->assertTrue( empty( $check['user_ID'] ) ); - $this->assertTrue( empty( $check['user_id'] ) ); + $this->assertEmpty( $check['user_ID'] ); + $this->assertEmpty( $check['user_id'] ); $this->assertSame( 'Some Guy', $check['comment_author'] ); $this->assertSame( $test_email, $check['comment_author_email'] ); $this->assertSame( $test_url, $check['comment_author_url'] ); @@ -189,8 +189,8 @@ public function test_get_all_form_ids_and_flatten_meta() { ); $this->assertSame( array( 1, 17, 11 ), $form_ids ); - $this->assertFalse( isset( $test_values['item_meta'][163] ) ); - $this->assertFalse( isset( $test_values['item_meta'][165] ) ); + $this->assertArrayNotHasKey(163, $test_values['item_meta']); + $this->assertArrayNotHasKey(165, $test_values['item_meta']); $this->assertSame( array( 'Option 2', 'Option 1' ), $test_values['item_meta'][162] ); $this->assertSame( array( 'John Doe' ), $test_values['item_meta'][118] ); $this->assertSame( 'John Doe', $test_values['item_meta'][1] ); @@ -273,9 +273,9 @@ public function test_skip_adding_values_to_akismet() { // Checkbox field shouldn't be skipped. foreach ( array( 'radio', 'radio_2', 'radio_3', 'radio_4', 'checkbox', 'select', 'scale', 'star', 'range', 'toggle' ) as $key ) { - $this->assertFalse( isset( $values['item_meta'][ $fields[ $key ]->id ] ) ); + $this->assertArrayNotHasKey($fields[ $key ]->id, $values['item_meta']); } - $this->assertTrue( isset( $values['item_meta'][ $fields['radio_5']->id ] ) ); + $this->assertArrayHasKey($fields['radio_5']->id, $values['item_meta']); } } diff --git a/tests/phpunit/fields/test_FrmField.php b/tests/phpunit/fields/test_FrmField.php index 67afbdb7b5..4fa1bbb62f 100644 --- a/tests/phpunit/fields/test_FrmField.php +++ b/tests/phpunit/fields/test_FrmField.php @@ -23,7 +23,7 @@ public function test_create() { ) ); $this->assertIsNumeric( $field_id ); - $this->assertTrue( $field_id > 0 ); + $this->assertGreaterThan(0, $field_id); } } diff --git a/tests/phpunit/fields/test_FrmFieldFormHtml.php b/tests/phpunit/fields/test_FrmFieldFormHtml.php index 4dd34d7a9e..a90916c94c 100644 --- a/tests/phpunit/fields/test_FrmFieldFormHtml.php +++ b/tests/phpunit/fields/test_FrmFieldFormHtml.php @@ -73,13 +73,13 @@ public function test_add_multiple_input_attributes() { // Assert html has the correct attributes if ( 'checkbox' !== $field_type['type'] && ( ! isset( $field_type['data_type'] ) || 'checkbox' !== $field_type['data_type'] ) ) { - $this->assertStringContainsString( 'aria-required="true"', $html ); + $this->assertStringContainsString( 'aria-required="true"', (string) $html ); } $expect_radio_group = 'radio' === $field_type['type'] || 'scale' === $field_type['type'] || ( isset( $data_type ) && 'radio' === $data_type ); if ( $expect_radio_group ) { - $this->assertStringContainsString( 'role="radiogroup"', $html ); + $this->assertStringContainsString( 'role="radiogroup"', (string) $html ); } } } diff --git a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php index 7cf9c66f65..9fd89b179f 100644 --- a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php +++ b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php @@ -108,7 +108,7 @@ public function test_with_sections() { $this->sync_current_field_once( 0 ); $this->section_helper = $this->get_private_property( $this->helper, 'section_helper' ); - $this->assertTrue( $this->section_helper instanceof FrmFieldGridHelper ); + $this->assertInstanceOf(\FrmFieldGridHelper::class, $this->section_helper); $this->assert_section_helper_size( 0 ); $this->helper->set_field( $half_width_field ); @@ -122,12 +122,12 @@ public function test_with_sections() { $this->sync_current_field_once( 6 ); $this->section_helper = $this->get_private_property( $this->helper, 'section_helper' ); - $this->assertTrue( empty( $this->section_helper ) ); + $this->assertEmpty( $this->section_helper ); $this->helper->set_field( $quarter_width_section ); $this->sync_current_field_once( 6 ); $this->section_helper = $this->get_private_property( $this->helper, 'section_helper' ); - $this->assertTrue( $this->section_helper instanceof FrmFieldGridHelper ); + $this->assertInstanceOf(\FrmFieldGridHelper::class, $this->section_helper); $this->assert_section_helper_size( 0 ); $this->helper->set_field( $half_width_field ); diff --git a/tests/phpunit/fields/test_FrmFieldName.php b/tests/phpunit/fields/test_FrmFieldName.php index 7e3652fd1a..09df485b0b 100644 --- a/tests/phpunit/fields/test_FrmFieldName.php +++ b/tests/phpunit/fields/test_FrmFieldName.php @@ -19,8 +19,8 @@ public function test_get_processed_sub_fields() { $processed_sub_fields = $this->run_private_method( array( $name_field, 'get_processed_sub_fields' ) ); $this->assertSame( array( 'first', 'middle', 'last' ), array_keys( $processed_sub_fields ) ); - $this->assertStringContainsString( 'frm4', $processed_sub_fields['first']['wrapper_classes'] ); - $this->assertStringContainsString( 'frm4', $processed_sub_fields['middle']['wrapper_classes'] ); - $this->assertStringContainsString( 'frm4', $processed_sub_fields['last']['wrapper_classes'] ); + $this->assertStringContainsString( 'frm4', (string) $processed_sub_fields['first']['wrapper_classes'] ); + $this->assertStringContainsString( 'frm4', (string) $processed_sub_fields['middle']['wrapper_classes'] ); + $this->assertStringContainsString( 'frm4', (string) $processed_sub_fields['last']['wrapper_classes'] ); } } diff --git a/tests/phpunit/fields/test_FrmFieldValidate.php b/tests/phpunit/fields/test_FrmFieldValidate.php index 0e608ec366..5cf417673d 100644 --- a/tests/phpunit/fields/test_FrmFieldValidate.php +++ b/tests/phpunit/fields/test_FrmFieldValidate.php @@ -180,7 +180,7 @@ public function test_url_value() { $this->set_required_field( $field ); $errors = $this->check_single_value( array( $field->id => 'http://' ) ); - $this->assertTrue( isset( $errors[ 'field' . $field->id ] ), 'http:// passed required validation ' . print_r( $errors, 1 ) ); + $this->assertArrayHasKey( 'field' . $field->id, $errors, 'http:// passed required validation ' . print_r( $errors, 1 ) ); } /** @@ -192,13 +192,13 @@ public function test_email_value() { $this->set_required_field( $field ); $errors = $this->check_single_value( array( $field->id => 'notemail@' ) ); - $this->assertTrue( isset( $errors[ 'field' . $field->id ] ), 'Poorly formatted email passed validation ' . print_r( $errors, 1 ) ); + $this->assertArrayHasKey( 'field' . $field->id, $errors, 'Poorly formatted email passed validation ' . print_r( $errors, 1 ) ); $errors = $this->check_single_value( array( $field->id => '' ) ); - $this->assertTrue( isset( $errors[ 'field' . $field->id ] ), 'Email email passed required validation ' . print_r( $errors, 1 ) ); + $this->assertArrayHasKey( 'field' . $field->id, $errors, 'Email email passed required validation ' . print_r( $errors, 1 ) ); $errors = $this->check_single_value( array( $field->id => 'email@example.com' ) ); - $this->assertFalse( isset( $errors[ 'field' . $field->id ] ), 'Properly formatted email did not pass validation ' . print_r( $errors, 1 ) ); + $this->assertArrayNotHasKey( 'field' . $field->id, $errors, 'Properly formatted email did not pass validation ' . print_r( $errors, 1 ) ); } /** @@ -207,7 +207,7 @@ public function test_email_value() { public function test_number_validation() { $field = $this->factory->field->get_object_by_id( $this->get_field_key( 'number' ) ); $errors = $this->check_single_value( array( $field->id => '10.5' ) ); - $this->assertFalse( isset( $errors[ 'field' . $field->id ] ), 'Number failed validation ' . print_r( $errors, 1 ) ); + $this->assertArrayNotHasKey( 'field' . $field->id, $errors, 'Number failed validation ' . print_r( $errors, 1 ) ); $field = $this->factory->field->create_and_get( array( @@ -222,16 +222,16 @@ public function test_number_validation() { $this->assertSame( 20, $field->field_options['maxnum'] ); $errors = $this->check_single_value( array( $field->id => '10.5' ) ); - $this->assertFalse( isset( $errors[ 'field' . $field->id ] ), 'Number failed range validation ' . print_r( $errors, 1 ) ); + $this->assertArrayNotHasKey( 'field' . $field->id, $errors, 'Number failed range validation ' . print_r( $errors, 1 ) ); $errors = $this->check_single_value( array( $field->id => 'not numeric' ) ); - $this->assertTrue( isset( $errors[ 'field' . $field->id ] ), 'Number failed numeric validation' ); + $this->assertArrayHasKey( 'field' . $field->id, $errors, 'Number failed numeric validation' ); $errors = $this->check_single_value( array( $field->id => '25' ) ); - $this->assertTrue( isset( $errors[ 'field' . $field->id ] ), 'Number failed max range validation' ); + $this->assertArrayHasKey( 'field' . $field->id, $errors, 'Number failed max range validation' ); $errors = $this->check_single_value( array( $field->id => '-25' ) ); - $this->assertTrue( isset( $errors[ 'field' . $field->id ] ), 'Number failed min range validation' ); + $this->assertArrayHasKey( 'field' . $field->id, $errors, 'Number failed min range validation' ); } protected function set_required_fields( $fields ) { diff --git a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php index 7b779ac1c5..7f82309331 100644 --- a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php +++ b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php @@ -52,10 +52,10 @@ public function test_render() { $output = ob_get_clean(); // Assertions for verifying specific elements in the rendered output. - $this->assertStringContainsString( 'id="frm-form-templates-page"', $output, 'The output does not contain the page ID.' ); - $this->assertStringContainsString( 'id="frm-new-template"', $output, 'The hidden form (frm-new-template) is missing from the output.' ); - $this->assertStringContainsString( 'id="frm-page-skeleton-sidebar"', $output, 'The sidebar (frm-page-skeleton-sidebar) is missing from the output.' ); - $this->assertStringContainsString( 'id="post-body-content"', $output, 'The post body content (post-body-content) is missing from the output.' ); + $this->assertStringContainsString( 'id="frm-form-templates-page"', (string) $output, 'The output does not contain the page ID.' ); + $this->assertStringContainsString( 'id="frm-new-template"', (string) $output, 'The hidden form (frm-new-template) is missing from the output.' ); + $this->assertStringContainsString( 'id="frm-page-skeleton-sidebar"', (string) $output, 'The sidebar (frm-page-skeleton-sidebar) is missing from the output.' ); + $this->assertStringContainsString( 'id="post-body-content"', (string) $output, 'The post body content (post-body-content) is missing from the output.' ); } /** @@ -74,14 +74,14 @@ public function test_render_modal() { $this->controller::render_modal(); $output = ob_get_clean(); - $this->assertStringContainsString( 'id="frm-create-template-modal"', $output ); + $this->assertStringContainsString( 'id="frm-create-template-modal"', (string) $output ); // Case: Free license, not expired. $this->set_private_property( $this->controller, 'is_expired', false ); // Assertions for free license. - $this->assertStringContainsString( 'id="frm-form-upgrade-modal"', $output ); - $this->assertStringNotContainsString( 'id="frm-renew-modal"', $output ); + $this->assertStringContainsString( 'id="frm-form-upgrade-modal"', (string) $output ); + $this->assertStringNotContainsString( 'id="frm-renew-modal"', (string) $output ); // Case: Expired account. $this->set_private_property( $this->controller, 'is_expired', true ); @@ -91,7 +91,7 @@ public function test_render_modal() { $output = ob_get_clean(); // Assertions for expired account. - $this->assertStringContainsString( 'id="frm-renew-modal"', $output ); + $this->assertStringContainsString( 'id="frm-renew-modal"', (string) $output ); // Case: Not on form templates page. $_GET['page'] = 'other-page'; @@ -133,7 +133,7 @@ public function test_init_favorite_templates() { // Verify the favorite templates are correctly initialized. $this->assertIsArray( $favorites, 'Favorite templates should be an array.' ); - $this->assertTrue( isset( $favorites['default'] ), 'Missing default in favorites.' ); + $this->assertArrayHasKey( 'default', $favorites, 'Missing default in favorites.' ); $expected = array_merge( $test_favorite, $default ); $this->assertEquals( $expected, $favorites, 'Favorite templates should match the example data.' ); diff --git a/tests/phpunit/forms/test_FrmForm.php b/tests/phpunit/forms/test_FrmForm.php index 7c0b58ad4d..0a77f8c17e 100644 --- a/tests/phpunit/forms/test_FrmForm.php +++ b/tests/phpunit/forms/test_FrmForm.php @@ -62,7 +62,7 @@ public function test_destroy() { FrmForm::destroy( $form->id ); $form_exists = FrmForm::getOne( $form->id ); - $this->assertEmpty( $form_exists, 'Failed to delete form ' . $form->form_key ); + $this->assertNotInstanceOf( \stdClass::class, $form_exists, 'Failed to delete form ' . $form->form_key ); $subforms_exist = FrmForm::getAll( array( 'parent_form_id' => $form->id ) ); $this->assertEmpty( $subforms_exist, 'Failed to delete child forms for parent form ' . $form->form_key ); diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index 6d6201c803..5875708b19 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -8,7 +8,7 @@ class test_FrmFormsController extends FrmUnitTest { public function test_register_widgets() { global $wp_widget_factory; - $this->assertTrue( isset( $wp_widget_factory->widgets['FrmShowForm'] ) ); + $this->assertArrayHasKey('FrmShowForm', $wp_widget_factory->widgets); } public function test_head() { @@ -281,7 +281,7 @@ public function test_redirect_after_create() { $this->assertTrue( headers_sent() ); // Since headers are sent by phpunit, we will get the js redirect. - $this->assertStringContainsString( 'window.location="' . $expected_url . '"', $response ); + $this->assertStringContainsString( 'window.location="' . $expected_url . '"', (string) $response ); } /** @@ -400,7 +400,7 @@ public function test_redirect_in_new_tab() { $this->assertTrue( headers_sent() ); // Since headers are sent by phpunit, we will get the js redirect. - $this->assertStringContainsString( 'window.open("http://example.com"', $response ); - $this->assertStringContainsString( 'target="_blank">Click here', $response ); + $this->assertStringContainsString( 'window.open("http://example.com"', (string) $response ); + $this->assertStringContainsString( 'target="_blank">Click here', (string) $response ); } } diff --git a/tests/phpunit/forms/test_FrmOnSubmitAction.php b/tests/phpunit/forms/test_FrmOnSubmitAction.php index 6c661e5115..7e0b08e0bf 100644 --- a/tests/phpunit/forms/test_FrmOnSubmitAction.php +++ b/tests/phpunit/forms/test_FrmOnSubmitAction.php @@ -43,7 +43,7 @@ public function test_adding_sanitize_url_after_updating() { $updated_action = get_post( $action_id ); $post_content = (array) FrmAppHelper::maybe_json_decode( $updated_action->post_content ); - $this->assertFalse( empty( $post_content['success_url'] ) ); + $this->assertNotEmpty( $post_content['success_url'] ); $this->assertSame( 'https://example.com/?param=[' . $field_id . ' sanitize_url=1]', $post_content['success_url'] ); } } diff --git a/tests/phpunit/misc/test_FrmAddon.php b/tests/phpunit/misc/test_FrmAddon.php index 80d717aa72..18cdff0e47 100644 --- a/tests/phpunit/misc/test_FrmAddon.php +++ b/tests/phpunit/misc/test_FrmAddon.php @@ -10,8 +10,7 @@ class test_FrmAddon extends FrmUnitTest { public function setUp(): void { parent::setUp(); - $this->addon = $this->getMockBuilder( 'FrmTestAddon' ) - ->setMethods( null ) + $this->addon = $this->getMockBuilder( 'FrmTestAddon' )->setMethods() ->getMock(); } @@ -30,7 +29,7 @@ public function test_construct() { */ public function test_insert_installed_addon() { $plugins = apply_filters( 'frm_installed_addons', array() ); - $this->assertTrue( isset( $plugins['signature'] ) ); + $this->assertArrayHasKey('signature', $plugins); } /** diff --git a/tests/phpunit/misc/test_FrmAntiSpam.php b/tests/phpunit/misc/test_FrmAntiSpam.php index 8ea41d0941..5ebaa8fa0a 100644 --- a/tests/phpunit/misc/test_FrmAntiSpam.php +++ b/tests/phpunit/misc/test_FrmAntiSpam.php @@ -19,7 +19,7 @@ public function setUp(): void { public function test_get() { $token_string = $this->run_private_method( array( $this->antispam, 'get' ) ); $this->assertIsString( $token_string ); - $this->assertTrue( strlen( $token_string ) >= 32 ); + $this->assertGreaterThanOrEqual(32, strlen( $token_string )); } /** @@ -28,7 +28,7 @@ public function test_get() { public function test_get_antispam_secret_key() { $secret_key = $this->run_private_method( array( $this->antispam, 'get_antispam_secret_key' ) ); $this->assertIsString( $secret_key ); - $this->assertTrue( strlen( $secret_key ) >= 32 ); + $this->assertGreaterThanOrEqual(32, strlen( $secret_key )); } /** @@ -37,7 +37,7 @@ public function test_get_antispam_secret_key() { public function test_get_valid_tokens() { $valid_tokens = $this->run_private_method( array( $this->antispam, 'get_valid_tokens' ) ); $this->assertIsArray( $valid_tokens ); - $this->assertTrue( count( $valid_tokens ) >= 1 ); + $this->assertGreaterThanOrEqual(1, count( $valid_tokens )); } /** diff --git a/tests/phpunit/misc/test_FrmAppController.php b/tests/phpunit/misc/test_FrmAppController.php index f7decfd73c..a6e3567a56 100644 --- a/tests/phpunit/misc/test_FrmAppController.php +++ b/tests/phpunit/misc/test_FrmAppController.php @@ -68,14 +68,14 @@ public function test_add_admin_class() { $this->set_admin_screen(); $class = 'other-class'; $filtered_class = apply_filters( 'admin_body_class', $class ); - $this->assertStringContainsString( $class, $filtered_class, '"' . $class . '" is missing from admin classes' ); - $this->assertStringNotContainsString( 'frm-white-body', $filtered_class, '"frm-white-body" was added to admin classes' ); + $this->assertStringContainsString( $class, (string) $filtered_class, '"' . $class . '" is missing from admin classes' ); + $this->assertStringNotContainsString( 'frm-white-body', (string) $filtered_class, '"frm-white-body" was added to admin classes' ); $this->set_admin_screen( 'admin.php?page=formidable' ); $class = 'other-class'; $filtered_class = apply_filters( 'admin_body_class', $class ); - $this->assertStringContainsString( $class, $filtered_class, '"' . $class . '" is missing from admin classes' ); - $this->assertStringContainsString( ' frm-white-body', $filtered_class, '"frm-white-body" is missing from admin classes' ); + $this->assertStringContainsString( $class, (string) $filtered_class, '"' . $class . '" is missing from admin classes' ); + $this->assertStringContainsString( ' frm-white-body', (string) $filtered_class, '"frm-white-body" is missing from admin classes' ); } /** diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index 9f6771adfd..56f0284ffd 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -531,11 +531,11 @@ public function test_get_unique_key() { $column = 'field_key'; $name = 'lrk2p3994ed7b17086290a2b7c3ca5e65c944451f9c2d457602cae34661ec7f32998cc21b037a67695662e4b9fb7e177a5b28a6c0f'; $key = FrmAppHelper::get_unique_key( $name, $table_name, $column ); - $this->assertTrue( strlen( $key ) < 100, 'field key length should never be over 100' ); + $this->assertLessThan( 100, strlen( $key ), 'field key length should never be over 100' ); $name = 'key'; $key = FrmAppHelper::get_unique_key( $name, $table_name, $column ); - $this->assertTrue( 'key' !== $key, 'key is a reserved key so get_unique_key should never return it.' ); + $this->assertNotSame( 'key', $key, 'key is a reserved key so get_unique_key should never return it.' ); $name = 123; $key = FrmAppHelper::get_unique_key( $name, $table_name, $column ); @@ -563,7 +563,7 @@ public function test_get_unique_key() { $key = FrmAppHelper::get_unique_key( $name, $table_name, $column ); $this->assertNotSame( $name, $key, 'Field key should be unique' ); - $this->assertStringContainsString( '___', $key, 'Field key should contain custom separator' ); + $this->assertStringContainsString( '___', (string) $key, 'Field key should contain custom separator' ); $this->assertSame( strlen( $name ) + 4, strlen( $key ), 'Field key should be the previous key + 3 character separator + "2" incremented counter value' ); $this->assertSame( $name . '___2', $key ); @@ -573,7 +573,7 @@ public function test_get_unique_key() { $table_name = 'frm_forms'; $column = 'form_key'; $unique_key = FrmAppHelper::get_unique_key( $super_long_form_key, $table_name, $column ); - $this->assertTrue( strlen( $unique_key ) <= 70 ); + $this->assertLessThanOrEqual(70, strlen( $unique_key )); $this->assertNotSame( $super_long_form_key, $unique_key ); } diff --git a/tests/phpunit/misc/test_FrmCSVExportHelper.php b/tests/phpunit/misc/test_FrmCSVExportHelper.php index b8ad9a479f..f2e0ffc03b 100644 --- a/tests/phpunit/misc/test_FrmCSVExportHelper.php +++ b/tests/phpunit/misc/test_FrmCSVExportHelper.php @@ -168,10 +168,10 @@ public function test_generate_csv() { $csv_content = file_get_contents( $csv_path ); unlink( $csv_path ); - $this->assertStringContainsString( ',"Text Field Name",', $csv_content ); - $this->assertStringContainsString( ',"Timestamp",', $csv_content ); - $this->assertStringContainsString( ',"ID",', $csv_content ); - $this->assertStringContainsString( ',"Test Value",', $csv_content ); - $this->assertStringContainsString( ',"' . $entry->id . '",', $csv_content ); + $this->assertStringContainsString( ',"Text Field Name",', (string) $csv_content ); + $this->assertStringContainsString( ',"Timestamp",', (string) $csv_content ); + $this->assertStringContainsString( ',"ID",', (string) $csv_content ); + $this->assertStringContainsString( ',"Test Value",', (string) $csv_content ); + $this->assertStringContainsString( ',"' . $entry->id . '",', (string) $csv_content ); } } diff --git a/tests/phpunit/misc/test_FrmHooksController.php b/tests/phpunit/misc/test_FrmHooksController.php index 582d06f795..fc5baf492e 100644 --- a/tests/phpunit/misc/test_FrmHooksController.php +++ b/tests/phpunit/misc/test_FrmHooksController.php @@ -15,7 +15,7 @@ public function test_trigger_load_form_hooks() { foreach ( $expected_hooks as $tag => $function ) { $has_filter = has_filter( $tag, $function ); - $this->assertTrue( $has_filter !== false, 'The ' . $tag . ' hook is not loaded' ); + $this->assertNotFalse( $has_filter, 'The ' . $tag . ' hook is not loaded' ); } } } diff --git a/tests/phpunit/misc/test_FrmMisc.php b/tests/phpunit/misc/test_FrmMisc.php index ae4024ddc9..b4bf43685c 100644 --- a/tests/phpunit/misc/test_FrmMisc.php +++ b/tests/phpunit/misc/test_FrmMisc.php @@ -11,8 +11,8 @@ class test_FrmMisc extends FrmUnitTest { public function test_load_formidable_forms() { global $frm_vars; $this->assertNotEmpty( $frm_vars ); - $this->assertTrue( isset( $frm_vars['load_css'] ) ); - $this->assertTrue( isset( $frm_vars['pro_is_authorized'] ) ); + $this->assertArrayHasKey('load_css', $frm_vars); + $this->assertArrayHasKey('pro_is_authorized', $frm_vars); $this->assertSame( 0, has_action( 'init', 'FrmAppController::load_lang' ) ); } @@ -34,9 +34,9 @@ public function test_frm_class_autoloader() { public function test_no_references_to_map_files() { $popper_js = file_get_contents( FrmAppHelper::plugin_path() . '/js/popper.min.js' ); - $this->assertStringNotContainsString( 'sourceMappingURL=popper.min.js.map', $popper_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong + $this->assertStringNotContainsString( 'sourceMappingURL=popper.min.js.map', (string) $popper_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong $bootstrap_js = file_get_contents( FrmAppHelper::plugin_path() . '/js/bootstrap.min.js' ); - $this->assertStringNotContainsString( 'sourceMappingURL=bootstrap.min.js.map', $bootstrap_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong + $this->assertStringNotContainsString( 'sourceMappingURL=bootstrap.min.js.map', (string) $bootstrap_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong } } diff --git a/tests/phpunit/misc/test_FrmSimpleBlocksController.php b/tests/phpunit/misc/test_FrmSimpleBlocksController.php index 3fe3a6e497..04284e6adc 100644 --- a/tests/phpunit/misc/test_FrmSimpleBlocksController.php +++ b/tests/phpunit/misc/test_FrmSimpleBlocksController.php @@ -12,11 +12,11 @@ public function test_maybe_remove_fade_on_load_for_block_preview() { $_SERVER['CONTENT_TYPE'] = 'application/json'; if ( is_callable( 'wp_is_json_request' ) ) { - $this->assertStringNotContainsString( 'frm_logic_form', $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); + $this->assertStringNotContainsString( 'frm_logic_form', (string) $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); } unset( $_SERVER['HTTP_ACCEPT'], $_SERVER['CONTENT_TYPE'] ); - $this->assertStringContainsString( 'frm_logic_form', $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); + $this->assertStringContainsString( 'frm_logic_form', (string) $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); } private function maybe_remove_fade_on_load_for_block_preview( $form ) { diff --git a/tests/phpunit/misc/test_FrmSpamCheckDenylist.php b/tests/phpunit/misc/test_FrmSpamCheckDenylist.php index c41ef7526a..e5aceef937 100644 --- a/tests/phpunit/misc/test_FrmSpamCheckDenylist.php +++ b/tests/phpunit/misc/test_FrmSpamCheckDenylist.php @@ -2,8 +2,6 @@ class test_FrmSpamCheckDenylist extends FrmUnitTest { - private $form_id; - private $text_field_id; private $email_field_id; @@ -21,38 +19,38 @@ class test_FrmSpamCheckDenylist extends FrmUnitTest { public function setUp(): void { parent::setUp(); - $this->form_id = $this->factory->form->create( + $form_id = $this->factory->form->create( array( 'form_key' => 'test_form_spam', ) ); - $fields = FrmField::getAll( array( 'form_id' => $this->form_id ) ); + $fields = FrmField::getAll( array( 'form_id' => $form_id ) ); $this->text_field_id = $fields[0]->id; $this->email_field_id = $this->factory->field->create( array( 'type' => 'email', - 'form_id' => $this->form_id, + 'form_id' => $form_id, ) ); $this->name_field_id = $this->factory->field->create( array( 'type' => 'name', - 'form_id' => $this->form_id, + 'form_id' => $form_id, ) ); $this->email_field_id2 = $this->factory->field->create( array( 'type' => 'email', - 'form_id' => $this->form_id, + 'form_id' => $form_id, ) ); $this->default_values = array( - 'form_id' => $this->form_id, + 'form_id' => $form_id, 'item_meta' => array( $this->email_field_id => 'test@gmail.com', $this->text_field_id => 'this text contains test@domain.com', diff --git a/tests/phpunit/styles/test_FrmStyleApi.php b/tests/phpunit/styles/test_FrmStyleApi.php index 8bfabae268..f26dd9fa9e 100644 --- a/tests/phpunit/styles/test_FrmStyleApi.php +++ b/tests/phpunit/styles/test_FrmStyleApi.php @@ -29,9 +29,9 @@ public function test_get_api_info() { $this->assertIsArray( $first_style_template['icon'] ); $image = reset( $first_style_template['icon'] ); $this->assertStringStartsWith( 'https://', $image ); - $this->assertStringContainsString( '.png', $image ); + $this->assertStringContainsString( '.png', (string) $image ); // Question: Do we ever allow people to download a style template for free? Does WordPress allow this? - $this->assertTrue( ! isset( $first_style_template['url'] ), 'In lite we always expect the style template to be ' ); + $this->assertArrayNotHasKey( 'url', $first_style_template, 'In lite we always expect the style template to be ' ); } } diff --git a/tests/phpunit/styles/test_FrmStylesController.php b/tests/phpunit/styles/test_FrmStylesController.php index ad21823f7e..47c509537c 100644 --- a/tests/phpunit/styles/test_FrmStylesController.php +++ b/tests/phpunit/styles/test_FrmStylesController.php @@ -44,7 +44,7 @@ private function get_custom_stylesheet() { global $frm_vars; $frm_vars['css_loaded'] = false; $stylesheet_urls = FrmStylesController::custom_stylesheet(); - $this->assertTrue( isset( $stylesheet_urls['formidable'] ), 'The stylesheet array is empty' ); + $this->assertArrayHasKey( 'formidable', $stylesheet_urls, 'The stylesheet array is empty' ); return $stylesheet_urls; } @@ -73,7 +73,7 @@ public function test_save() { FrmStylesController::save(); $returned = ob_get_clean(); - $this->assertStringContainsString( 'Your styling settings have been saved.', $returned ); + $this->assertStringContainsString( 'Your styling settings have been saved.', (string) $returned ); $frm_style = new FrmStyle( $style->ID ); $updated_style = $frm_style->get_one(); $this->assertSame( $style->post_title . ' Updated', $updated_style->post_title ); diff --git a/tests/phpunit/styles/test_FrmStylesHelper.php b/tests/phpunit/styles/test_FrmStylesHelper.php index 13d6af07ff..5ee2576d20 100644 --- a/tests/phpunit/styles/test_FrmStylesHelper.php +++ b/tests/phpunit/styles/test_FrmStylesHelper.php @@ -10,12 +10,12 @@ class test_FrmStylesHelper extends FrmUnitTest { */ public function test_get_upload_base() { $base = FrmStylesHelper::get_upload_base(); - $this->assertTrue( isset( $base['baseurl'] ) ); - $this->assertStringContainsString( 'http://', $base['baseurl'] ); + $this->assertArrayHasKey('baseurl', $base); + $this->assertStringContainsString( 'http://', (string) $base['baseurl'] ); $_SERVER['HTTPS'] = 'on'; $base = FrmStylesHelper::get_upload_base(); - $this->assertStringContainsString( 'https://', $base['baseurl'] ); + $this->assertStringContainsString( 'https://', (string) $base['baseurl'] ); } /** diff --git a/tests/phpunit/xml/test_FrmXMLHelper.php b/tests/phpunit/xml/test_FrmXMLHelper.php index e69c812a32..d10ee27e2d 100644 --- a/tests/phpunit/xml/test_FrmXMLHelper.php +++ b/tests/phpunit/xml/test_FrmXMLHelper.php @@ -98,7 +98,7 @@ public function test_populate_postmeta() { $this->populate_postmeta( $post, $meta, $imported ); $this->assertArrayHasKey( 'postmeta', $post ); - $this->assertTrue( ! empty( $post['postmeta'] ) ); + $this->assertNotEmpty( $post['postmeta'] ); $this->assertArrayHasKey( 'frm_dyncontent', $post['postmeta'] ); $this->assertIsArray( $post['postmeta']['frm_dyncontent'] ); $this->assertSame( From 98cfb91a33cb294126bd9bf360ddb9f159c1d074 Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 24 Feb 2026 15:33:24 -0400 Subject: [PATCH 2/4] Undo the StringCastAssertStringContainsStringRector changes --- rector.php | 2 ++ .../test_FrmApplicationsController.php | 4 ++-- tests/phpunit/database/test_FrmMigrate.php | 2 +- tests/phpunit/emails/test_FrmEmail.php | 14 +++++++------- tests/phpunit/fields/test_FrmFieldFormHtml.php | 4 ++-- tests/phpunit/fields/test_FrmFieldName.php | 6 +++--- .../test_FrmFormTemplatesController.php | 16 ++++++++-------- tests/phpunit/forms/test_FrmFormsController.php | 6 +++--- tests/phpunit/misc/test_FrmAppController.php | 8 ++++---- tests/phpunit/misc/test_FrmAppHelper.php | 2 +- tests/phpunit/misc/test_FrmCSVExportHelper.php | 10 +++++----- tests/phpunit/misc/test_FrmMisc.php | 4 ++-- .../misc/test_FrmSimpleBlocksController.php | 4 ++-- tests/phpunit/styles/test_FrmStyleApi.php | 2 +- .../phpunit/styles/test_FrmStylesController.php | 2 +- tests/phpunit/styles/test_FrmStylesHelper.php | 4 ++-- 16 files changed, 46 insertions(+), 44 deletions(-) diff --git a/rector.php b/rector.php index 2617eb97bb..d8eb684b7c 100644 --- a/rector.php +++ b/rector.php @@ -72,6 +72,7 @@ use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector; use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; +use Rector\PHPUnit\CodeQuality\Rector\MethodCall\StringCastAssertStringContainsStringRector; return RectorConfig::configure() ->withBootstrapFiles( @@ -235,5 +236,6 @@ FinalizeTestCaseClassRector::class, PrivatizeFinalClassPropertyRector::class, StringClassNameToClassConstantRector::class, + StringCastAssertStringContainsStringRector::class, ) ); diff --git a/tests/phpunit/applications/test_FrmApplicationsController.php b/tests/phpunit/applications/test_FrmApplicationsController.php index 942d85f90a..2b4fdc41dd 100644 --- a/tests/phpunit/applications/test_FrmApplicationsController.php +++ b/tests/phpunit/applications/test_FrmApplicationsController.php @@ -12,7 +12,7 @@ public function test_landing_page() { ob_start(); FrmApplicationsController::landing_page(); $html = ob_get_clean(); - $this->assertStringContainsString( 'id="frm_applications_container"', (string) $html ); + $this->assertStringContainsString( 'id="frm_applications_container"', $html ); } /** @@ -48,6 +48,6 @@ public function test_render_applications_header() { $title = 'Applications'; FrmApplicationsController::render_applications_header( $title, 'index' ); $html = ob_get_clean(); - $this->assertStringContainsString( $title, (string) $html ); + $this->assertStringContainsString( $title, $html ); } } diff --git a/tests/phpunit/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index d4eced5e4e..8721970356 100644 --- a/tests/phpunit/database/test_FrmMigrate.php +++ b/tests/phpunit/database/test_FrmMigrate.php @@ -366,7 +366,7 @@ public function test_migrate_from_12_to_current() { $this->assertCount( 1, $form_actions, 'Old form settings are not converted to email action.' ); foreach ( $form_actions as $action ) { - $this->assertStringContainsString( 'emailto@test.com', (string) $action->post_content['email_to'] ); + $this->assertStringContainsString( 'emailto@test.com', $action->post_content['email_to'] ); } } diff --git a/tests/phpunit/emails/test_FrmEmail.php b/tests/phpunit/emails/test_FrmEmail.php index 165602f1b1..4e6d2cc0b6 100644 --- a/tests/phpunit/emails/test_FrmEmail.php +++ b/tests/phpunit/emails/test_FrmEmail.php @@ -476,8 +476,8 @@ protected function check_recipients( $expected, $mock_email, $cc_status = 'yes_c * @param array $mock_email */ protected function check_senders( $expected, $mock_email ) { - $this->assertStringContainsString( 'From: ' . $expected['from'], (string) $mock_email['header'], 'From does not match expected.' ); - $this->assertStringContainsString( 'Reply-To: ' . $expected['reply_to'], (string) $mock_email['header'], 'Reply-to does not match expected.' ); + $this->assertStringContainsString( 'From: ' . $expected['from'], $mock_email['header'], 'From does not match expected.' ); + $this->assertStringContainsString( 'Reply-To: ' . $expected['reply_to'], $mock_email['header'], 'Reply-to does not match expected.' ); } /** @@ -507,21 +507,21 @@ protected function check_message_body( $expected, $mock_email ) { * @param array $mock_email */ protected function check_content_type( $expected, $mock_email ) { - $this->assertStringContainsString( $expected['content_type'], (string) $mock_email['header'], 'Content type does not match expected.' ); + $this->assertStringContainsString( $expected['content_type'], $mock_email['header'], 'Content type does not match expected.' ); } /** * @param array $mock_email */ protected function check_no_cc_included( $mock_email ) { - $this->assertStringNotContainsString( 'Cc:', (string) $mock_email['header'], 'CC is included when it should not be.' ); + $this->assertStringNotContainsString( 'Cc:', $mock_email['header'], 'CC is included when it should not be.' ); } /** * @param array $mock_email */ protected function check_no_bcc_included( $mock_email ) { - $this->assertStringNotContainsString( 'Bcc:', (string) $mock_email['header'], 'BCC is included when it should not be.' ); + $this->assertStringNotContainsString( 'Bcc:', $mock_email['header'], 'BCC is included when it should not be.' ); } /** @@ -723,9 +723,9 @@ public function test_message_user_info() { $actual = $this->get_private_property( $email, 'message' ); if ( $setting['compare'] === 'Contains' ) { - $this->assertStringContainsString( 'Referrer:', (string) $actual ); + $this->assertStringContainsString( 'Referrer:', $actual ); } else { - $this->assertStringNotContainsString( 'Referrer:', (string) $actual ); + $this->assertStringNotContainsString( 'Referrer:', $actual ); } } } diff --git a/tests/phpunit/fields/test_FrmFieldFormHtml.php b/tests/phpunit/fields/test_FrmFieldFormHtml.php index a90916c94c..4dd34d7a9e 100644 --- a/tests/phpunit/fields/test_FrmFieldFormHtml.php +++ b/tests/phpunit/fields/test_FrmFieldFormHtml.php @@ -73,13 +73,13 @@ public function test_add_multiple_input_attributes() { // Assert html has the correct attributes if ( 'checkbox' !== $field_type['type'] && ( ! isset( $field_type['data_type'] ) || 'checkbox' !== $field_type['data_type'] ) ) { - $this->assertStringContainsString( 'aria-required="true"', (string) $html ); + $this->assertStringContainsString( 'aria-required="true"', $html ); } $expect_radio_group = 'radio' === $field_type['type'] || 'scale' === $field_type['type'] || ( isset( $data_type ) && 'radio' === $data_type ); if ( $expect_radio_group ) { - $this->assertStringContainsString( 'role="radiogroup"', (string) $html ); + $this->assertStringContainsString( 'role="radiogroup"', $html ); } } } diff --git a/tests/phpunit/fields/test_FrmFieldName.php b/tests/phpunit/fields/test_FrmFieldName.php index 09df485b0b..7e3652fd1a 100644 --- a/tests/phpunit/fields/test_FrmFieldName.php +++ b/tests/phpunit/fields/test_FrmFieldName.php @@ -19,8 +19,8 @@ public function test_get_processed_sub_fields() { $processed_sub_fields = $this->run_private_method( array( $name_field, 'get_processed_sub_fields' ) ); $this->assertSame( array( 'first', 'middle', 'last' ), array_keys( $processed_sub_fields ) ); - $this->assertStringContainsString( 'frm4', (string) $processed_sub_fields['first']['wrapper_classes'] ); - $this->assertStringContainsString( 'frm4', (string) $processed_sub_fields['middle']['wrapper_classes'] ); - $this->assertStringContainsString( 'frm4', (string) $processed_sub_fields['last']['wrapper_classes'] ); + $this->assertStringContainsString( 'frm4', $processed_sub_fields['first']['wrapper_classes'] ); + $this->assertStringContainsString( 'frm4', $processed_sub_fields['middle']['wrapper_classes'] ); + $this->assertStringContainsString( 'frm4', $processed_sub_fields['last']['wrapper_classes'] ); } } diff --git a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php index 7f82309331..ca1956938a 100644 --- a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php +++ b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php @@ -52,10 +52,10 @@ public function test_render() { $output = ob_get_clean(); // Assertions for verifying specific elements in the rendered output. - $this->assertStringContainsString( 'id="frm-form-templates-page"', (string) $output, 'The output does not contain the page ID.' ); - $this->assertStringContainsString( 'id="frm-new-template"', (string) $output, 'The hidden form (frm-new-template) is missing from the output.' ); - $this->assertStringContainsString( 'id="frm-page-skeleton-sidebar"', (string) $output, 'The sidebar (frm-page-skeleton-sidebar) is missing from the output.' ); - $this->assertStringContainsString( 'id="post-body-content"', (string) $output, 'The post body content (post-body-content) is missing from the output.' ); + $this->assertStringContainsString( 'id="frm-form-templates-page"', $output, 'The output does not contain the page ID.' ); + $this->assertStringContainsString( 'id="frm-new-template"', $output, 'The hidden form (frm-new-template) is missing from the output.' ); + $this->assertStringContainsString( 'id="frm-page-skeleton-sidebar"', $output, 'The sidebar (frm-page-skeleton-sidebar) is missing from the output.' ); + $this->assertStringContainsString( 'id="post-body-content"', $output, 'The post body content (post-body-content) is missing from the output.' ); } /** @@ -74,14 +74,14 @@ public function test_render_modal() { $this->controller::render_modal(); $output = ob_get_clean(); - $this->assertStringContainsString( 'id="frm-create-template-modal"', (string) $output ); + $this->assertStringContainsString( 'id="frm-create-template-modal"', $output ); // Case: Free license, not expired. $this->set_private_property( $this->controller, 'is_expired', false ); // Assertions for free license. - $this->assertStringContainsString( 'id="frm-form-upgrade-modal"', (string) $output ); - $this->assertStringNotContainsString( 'id="frm-renew-modal"', (string) $output ); + $this->assertStringContainsString( 'id="frm-form-upgrade-modal"', $output ); + $this->assertStringNotContainsString( 'id="frm-renew-modal"', $output ); // Case: Expired account. $this->set_private_property( $this->controller, 'is_expired', true ); @@ -91,7 +91,7 @@ public function test_render_modal() { $output = ob_get_clean(); // Assertions for expired account. - $this->assertStringContainsString( 'id="frm-renew-modal"', (string) $output ); + $this->assertStringContainsString( 'id="frm-renew-modal"', $output ); // Case: Not on form templates page. $_GET['page'] = 'other-page'; diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index 5875708b19..870be2bc20 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -281,7 +281,7 @@ public function test_redirect_after_create() { $this->assertTrue( headers_sent() ); // Since headers are sent by phpunit, we will get the js redirect. - $this->assertStringContainsString( 'window.location="' . $expected_url . '"', (string) $response ); + $this->assertStringContainsString( 'window.location="' . $expected_url . '"', $response ); } /** @@ -400,7 +400,7 @@ public function test_redirect_in_new_tab() { $this->assertTrue( headers_sent() ); // Since headers are sent by phpunit, we will get the js redirect. - $this->assertStringContainsString( 'window.open("http://example.com"', (string) $response ); - $this->assertStringContainsString( 'target="_blank">Click here', (string) $response ); + $this->assertStringContainsString( 'window.open("http://example.com"', $response ); + $this->assertStringContainsString( 'target="_blank">Click here', $response ); } } diff --git a/tests/phpunit/misc/test_FrmAppController.php b/tests/phpunit/misc/test_FrmAppController.php index a6e3567a56..f7decfd73c 100644 --- a/tests/phpunit/misc/test_FrmAppController.php +++ b/tests/phpunit/misc/test_FrmAppController.php @@ -68,14 +68,14 @@ public function test_add_admin_class() { $this->set_admin_screen(); $class = 'other-class'; $filtered_class = apply_filters( 'admin_body_class', $class ); - $this->assertStringContainsString( $class, (string) $filtered_class, '"' . $class . '" is missing from admin classes' ); - $this->assertStringNotContainsString( 'frm-white-body', (string) $filtered_class, '"frm-white-body" was added to admin classes' ); + $this->assertStringContainsString( $class, $filtered_class, '"' . $class . '" is missing from admin classes' ); + $this->assertStringNotContainsString( 'frm-white-body', $filtered_class, '"frm-white-body" was added to admin classes' ); $this->set_admin_screen( 'admin.php?page=formidable' ); $class = 'other-class'; $filtered_class = apply_filters( 'admin_body_class', $class ); - $this->assertStringContainsString( $class, (string) $filtered_class, '"' . $class . '" is missing from admin classes' ); - $this->assertStringContainsString( ' frm-white-body', (string) $filtered_class, '"frm-white-body" is missing from admin classes' ); + $this->assertStringContainsString( $class, $filtered_class, '"' . $class . '" is missing from admin classes' ); + $this->assertStringContainsString( ' frm-white-body', $filtered_class, '"frm-white-body" is missing from admin classes' ); } /** diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index 56f0284ffd..3601d26c25 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -563,7 +563,7 @@ public function test_get_unique_key() { $key = FrmAppHelper::get_unique_key( $name, $table_name, $column ); $this->assertNotSame( $name, $key, 'Field key should be unique' ); - $this->assertStringContainsString( '___', (string) $key, 'Field key should contain custom separator' ); + $this->assertStringContainsString( '___', $key, 'Field key should contain custom separator' ); $this->assertSame( strlen( $name ) + 4, strlen( $key ), 'Field key should be the previous key + 3 character separator + "2" incremented counter value' ); $this->assertSame( $name . '___2', $key ); diff --git a/tests/phpunit/misc/test_FrmCSVExportHelper.php b/tests/phpunit/misc/test_FrmCSVExportHelper.php index f2e0ffc03b..b8ad9a479f 100644 --- a/tests/phpunit/misc/test_FrmCSVExportHelper.php +++ b/tests/phpunit/misc/test_FrmCSVExportHelper.php @@ -168,10 +168,10 @@ public function test_generate_csv() { $csv_content = file_get_contents( $csv_path ); unlink( $csv_path ); - $this->assertStringContainsString( ',"Text Field Name",', (string) $csv_content ); - $this->assertStringContainsString( ',"Timestamp",', (string) $csv_content ); - $this->assertStringContainsString( ',"ID",', (string) $csv_content ); - $this->assertStringContainsString( ',"Test Value",', (string) $csv_content ); - $this->assertStringContainsString( ',"' . $entry->id . '",', (string) $csv_content ); + $this->assertStringContainsString( ',"Text Field Name",', $csv_content ); + $this->assertStringContainsString( ',"Timestamp",', $csv_content ); + $this->assertStringContainsString( ',"ID",', $csv_content ); + $this->assertStringContainsString( ',"Test Value",', $csv_content ); + $this->assertStringContainsString( ',"' . $entry->id . '",', $csv_content ); } } diff --git a/tests/phpunit/misc/test_FrmMisc.php b/tests/phpunit/misc/test_FrmMisc.php index b4bf43685c..f65169bbdd 100644 --- a/tests/phpunit/misc/test_FrmMisc.php +++ b/tests/phpunit/misc/test_FrmMisc.php @@ -34,9 +34,9 @@ public function test_frm_class_autoloader() { public function test_no_references_to_map_files() { $popper_js = file_get_contents( FrmAppHelper::plugin_path() . '/js/popper.min.js' ); - $this->assertStringNotContainsString( 'sourceMappingURL=popper.min.js.map', (string) $popper_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong + $this->assertStringNotContainsString( 'sourceMappingURL=popper.min.js.map', $popper_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong $bootstrap_js = file_get_contents( FrmAppHelper::plugin_path() . '/js/bootstrap.min.js' ); - $this->assertStringNotContainsString( 'sourceMappingURL=bootstrap.min.js.map', (string) $bootstrap_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong + $this->assertStringNotContainsString( 'sourceMappingURL=bootstrap.min.js.map', $bootstrap_js, 'We do not want the popper JS file to include a source map reference. Since the sourcem ap is not included, this shows 404 errors in Safari.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong } } diff --git a/tests/phpunit/misc/test_FrmSimpleBlocksController.php b/tests/phpunit/misc/test_FrmSimpleBlocksController.php index 04284e6adc..3fe3a6e497 100644 --- a/tests/phpunit/misc/test_FrmSimpleBlocksController.php +++ b/tests/phpunit/misc/test_FrmSimpleBlocksController.php @@ -12,11 +12,11 @@ public function test_maybe_remove_fade_on_load_for_block_preview() { $_SERVER['CONTENT_TYPE'] = 'application/json'; if ( is_callable( 'wp_is_json_request' ) ) { - $this->assertStringNotContainsString( 'frm_logic_form', (string) $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); + $this->assertStringNotContainsString( 'frm_logic_form', $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); } unset( $_SERVER['HTTP_ACCEPT'], $_SERVER['CONTENT_TYPE'] ); - $this->assertStringContainsString( 'frm_logic_form', (string) $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); + $this->assertStringContainsString( 'frm_logic_form', $this->maybe_remove_fade_on_load_for_block_preview( $form ) ); } private function maybe_remove_fade_on_load_for_block_preview( $form ) { diff --git a/tests/phpunit/styles/test_FrmStyleApi.php b/tests/phpunit/styles/test_FrmStyleApi.php index f26dd9fa9e..64d5e4717b 100644 --- a/tests/phpunit/styles/test_FrmStyleApi.php +++ b/tests/phpunit/styles/test_FrmStyleApi.php @@ -29,7 +29,7 @@ public function test_get_api_info() { $this->assertIsArray( $first_style_template['icon'] ); $image = reset( $first_style_template['icon'] ); $this->assertStringStartsWith( 'https://', $image ); - $this->assertStringContainsString( '.png', (string) $image ); + $this->assertStringContainsString( '.png', $image ); // Question: Do we ever allow people to download a style template for free? Does WordPress allow this? $this->assertArrayNotHasKey( 'url', $first_style_template, 'In lite we always expect the style template to be ' ); diff --git a/tests/phpunit/styles/test_FrmStylesController.php b/tests/phpunit/styles/test_FrmStylesController.php index 47c509537c..b0cb69e350 100644 --- a/tests/phpunit/styles/test_FrmStylesController.php +++ b/tests/phpunit/styles/test_FrmStylesController.php @@ -73,7 +73,7 @@ public function test_save() { FrmStylesController::save(); $returned = ob_get_clean(); - $this->assertStringContainsString( 'Your styling settings have been saved.', (string) $returned ); + $this->assertStringContainsString( 'Your styling settings have been saved.', $returned ); $frm_style = new FrmStyle( $style->ID ); $updated_style = $frm_style->get_one(); $this->assertSame( $style->post_title . ' Updated', $updated_style->post_title ); diff --git a/tests/phpunit/styles/test_FrmStylesHelper.php b/tests/phpunit/styles/test_FrmStylesHelper.php index 5ee2576d20..4e8bbc5f0f 100644 --- a/tests/phpunit/styles/test_FrmStylesHelper.php +++ b/tests/phpunit/styles/test_FrmStylesHelper.php @@ -11,11 +11,11 @@ class test_FrmStylesHelper extends FrmUnitTest { public function test_get_upload_base() { $base = FrmStylesHelper::get_upload_base(); $this->assertArrayHasKey('baseurl', $base); - $this->assertStringContainsString( 'http://', (string) $base['baseurl'] ); + $this->assertStringContainsString( 'http://', $base['baseurl'] ); $_SERVER['HTTPS'] = 'on'; $base = FrmStylesHelper::get_upload_base(); - $this->assertStringContainsString( 'https://', (string) $base['baseurl'] ); + $this->assertStringContainsString( 'https://', $base['baseurl'] ); } /** From ff83f98fc87bcd23a98abf8e908a5e58aee9028c Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 24 Feb 2026 15:35:30 -0400 Subject: [PATCH 3/4] Fix failing test issues --- tests/phpunit/entries/test_FrmEntry.php | 2 +- tests/phpunit/entries/test_FrmEntryValidate.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/entries/test_FrmEntry.php b/tests/phpunit/entries/test_FrmEntry.php index ae13c35dcc..a9afc627a7 100644 --- a/tests/phpunit/entries/test_FrmEntry.php +++ b/tests/phpunit/entries/test_FrmEntry.php @@ -62,7 +62,7 @@ public function test_getAll() { $first_item = reset( $items ); $this->assertIsObject( $first_item ); - $this->assertEmpty( $first_item->metas, 'Entries should not include metas unless $meta = true is set.' ); + $this->assertObjectNotHasProperty( 'metas', $first_item, 'Entries should not include metas unless $meta = true is set.' ); // Test with $meta = true. $items = FrmEntry::getAll( array( 'it.form_id' => $form->id ), '', '', true, false ); diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php index 310c8b5c17..c1515511df 100644 --- a/tests/phpunit/entries/test_FrmEntryValidate.php +++ b/tests/phpunit/entries/test_FrmEntryValidate.php @@ -56,8 +56,8 @@ public function test_get_spam_check_user_info() { wp_set_current_user( null ); $this->run_private_method( array( 'FrmEntryValidate', 'prepare_values_for_spam_check' ), array( &$values ) ); $check = $this->get_spam_check_user_info( $values ); - $this->assertEmpty( $check['user_ID'] ); - $this->assertEmpty( $check['user_id'] ); + $this->assertArrayNotHasKey( 'user_ID', $check ); + $this->assertArrayNotHasKey( 'user_id', $check ); $this->assertSame( 'Some Guy', $check['comment_author'] ); $this->assertSame( $test_email, $check['comment_author_email'] ); $this->assertSame( $test_url, $check['comment_author_url'] ); From ef327c9af1d4fb9061a2d719aeba1049903ffddc Mon Sep 17 00:00:00 2001 From: Mike Letellier Date: Tue, 24 Feb 2026 15:37:05 -0400 Subject: [PATCH 4/4] Run phpcbf to fix spacing isuses --- tests/phpunit/emails/test_FrmEmailSummaryHelper.php | 8 ++++---- tests/phpunit/entries/test_FrmEntryValidate.php | 8 ++++---- tests/phpunit/fields/test_FrmField.php | 2 +- tests/phpunit/fields/test_FrmFieldGridHelper.php.php | 4 ++-- tests/phpunit/forms/test_FrmFormsController.php | 2 +- tests/phpunit/misc/test_FrmAddon.php | 2 +- tests/phpunit/misc/test_FrmAntiSpam.php | 6 +++--- tests/phpunit/misc/test_FrmAppHelper.php | 2 +- tests/phpunit/misc/test_FrmMisc.php | 4 ++-- tests/phpunit/styles/test_FrmStylesHelper.php | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php index 210d47672b..813d023b4d 100644 --- a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php +++ b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php @@ -13,9 +13,9 @@ public function test_get_options() { array( 'FrmEmailSummaryHelper', 'get_options' ) ); - $this->assertArrayHasKey('last_monthly', $options); - $this->assertArrayHasKey('last_yearly', $options); - $this->assertArrayHasKey('renewal_date', $options); + $this->assertArrayHasKey( 'last_monthly', $options ); + $this->assertArrayHasKey( 'last_yearly', $options ); + $this->assertArrayHasKey( 'renewal_date', $options ); } public function test_get_date_obj() { @@ -24,7 +24,7 @@ public function test_get_date_obj() { array( '2023-08-13' ) ); - $this->assertInstanceOf(\DateTime::class, $date); + $this->assertInstanceOf( \DateTime::class, $date ); $this->assertSame( '2023-08-13', $date->format( 'Y-m-d' ) ); $this->assertFalse( diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php index c1515511df..5ea1ce807f 100644 --- a/tests/phpunit/entries/test_FrmEntryValidate.php +++ b/tests/phpunit/entries/test_FrmEntryValidate.php @@ -189,8 +189,8 @@ public function test_get_all_form_ids_and_flatten_meta() { ); $this->assertSame( array( 1, 17, 11 ), $form_ids ); - $this->assertArrayNotHasKey(163, $test_values['item_meta']); - $this->assertArrayNotHasKey(165, $test_values['item_meta']); + $this->assertArrayNotHasKey( 163, $test_values['item_meta'] ); + $this->assertArrayNotHasKey( 165, $test_values['item_meta'] ); $this->assertSame( array( 'Option 2', 'Option 1' ), $test_values['item_meta'][162] ); $this->assertSame( array( 'John Doe' ), $test_values['item_meta'][118] ); $this->assertSame( 'John Doe', $test_values['item_meta'][1] ); @@ -273,9 +273,9 @@ public function test_skip_adding_values_to_akismet() { // Checkbox field shouldn't be skipped. foreach ( array( 'radio', 'radio_2', 'radio_3', 'radio_4', 'checkbox', 'select', 'scale', 'star', 'range', 'toggle' ) as $key ) { - $this->assertArrayNotHasKey($fields[ $key ]->id, $values['item_meta']); + $this->assertArrayNotHasKey( $fields[ $key ]->id, $values['item_meta'] ); } - $this->assertArrayHasKey($fields['radio_5']->id, $values['item_meta']); + $this->assertArrayHasKey( $fields['radio_5']->id, $values['item_meta'] ); } } diff --git a/tests/phpunit/fields/test_FrmField.php b/tests/phpunit/fields/test_FrmField.php index 4fa1bbb62f..f99d29a64d 100644 --- a/tests/phpunit/fields/test_FrmField.php +++ b/tests/phpunit/fields/test_FrmField.php @@ -23,7 +23,7 @@ public function test_create() { ) ); $this->assertIsNumeric( $field_id ); - $this->assertGreaterThan(0, $field_id); + $this->assertGreaterThan( 0, $field_id ); } } diff --git a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php index 9fd89b179f..8bdf83cb49 100644 --- a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php +++ b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php @@ -108,7 +108,7 @@ public function test_with_sections() { $this->sync_current_field_once( 0 ); $this->section_helper = $this->get_private_property( $this->helper, 'section_helper' ); - $this->assertInstanceOf(\FrmFieldGridHelper::class, $this->section_helper); + $this->assertInstanceOf( \FrmFieldGridHelper::class, $this->section_helper ); $this->assert_section_helper_size( 0 ); $this->helper->set_field( $half_width_field ); @@ -127,7 +127,7 @@ public function test_with_sections() { $this->helper->set_field( $quarter_width_section ); $this->sync_current_field_once( 6 ); $this->section_helper = $this->get_private_property( $this->helper, 'section_helper' ); - $this->assertInstanceOf(\FrmFieldGridHelper::class, $this->section_helper); + $this->assertInstanceOf( \FrmFieldGridHelper::class, $this->section_helper ); $this->assert_section_helper_size( 0 ); $this->helper->set_field( $half_width_field ); diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index 870be2bc20..85171ec0c7 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -8,7 +8,7 @@ class test_FrmFormsController extends FrmUnitTest { public function test_register_widgets() { global $wp_widget_factory; - $this->assertArrayHasKey('FrmShowForm', $wp_widget_factory->widgets); + $this->assertArrayHasKey( 'FrmShowForm', $wp_widget_factory->widgets ); } public function test_head() { diff --git a/tests/phpunit/misc/test_FrmAddon.php b/tests/phpunit/misc/test_FrmAddon.php index 18cdff0e47..dffd0b6070 100644 --- a/tests/phpunit/misc/test_FrmAddon.php +++ b/tests/phpunit/misc/test_FrmAddon.php @@ -29,7 +29,7 @@ public function test_construct() { */ public function test_insert_installed_addon() { $plugins = apply_filters( 'frm_installed_addons', array() ); - $this->assertArrayHasKey('signature', $plugins); + $this->assertArrayHasKey( 'signature', $plugins ); } /** diff --git a/tests/phpunit/misc/test_FrmAntiSpam.php b/tests/phpunit/misc/test_FrmAntiSpam.php index 5ebaa8fa0a..59b749ac7d 100644 --- a/tests/phpunit/misc/test_FrmAntiSpam.php +++ b/tests/phpunit/misc/test_FrmAntiSpam.php @@ -19,7 +19,7 @@ public function setUp(): void { public function test_get() { $token_string = $this->run_private_method( array( $this->antispam, 'get' ) ); $this->assertIsString( $token_string ); - $this->assertGreaterThanOrEqual(32, strlen( $token_string )); + $this->assertGreaterThanOrEqual( 32, strlen( $token_string ) ); } /** @@ -28,7 +28,7 @@ public function test_get() { public function test_get_antispam_secret_key() { $secret_key = $this->run_private_method( array( $this->antispam, 'get_antispam_secret_key' ) ); $this->assertIsString( $secret_key ); - $this->assertGreaterThanOrEqual(32, strlen( $secret_key )); + $this->assertGreaterThanOrEqual( 32, strlen( $secret_key ) ); } /** @@ -37,7 +37,7 @@ public function test_get_antispam_secret_key() { public function test_get_valid_tokens() { $valid_tokens = $this->run_private_method( array( $this->antispam, 'get_valid_tokens' ) ); $this->assertIsArray( $valid_tokens ); - $this->assertGreaterThanOrEqual(1, count( $valid_tokens )); + $this->assertGreaterThanOrEqual( 1, count( $valid_tokens ) ); } /** diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index 3601d26c25..b3eeb159d6 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -573,7 +573,7 @@ public function test_get_unique_key() { $table_name = 'frm_forms'; $column = 'form_key'; $unique_key = FrmAppHelper::get_unique_key( $super_long_form_key, $table_name, $column ); - $this->assertLessThanOrEqual(70, strlen( $unique_key )); + $this->assertLessThanOrEqual( 70, strlen( $unique_key ) ); $this->assertNotSame( $super_long_form_key, $unique_key ); } diff --git a/tests/phpunit/misc/test_FrmMisc.php b/tests/phpunit/misc/test_FrmMisc.php index f65169bbdd..1d69c6bdc4 100644 --- a/tests/phpunit/misc/test_FrmMisc.php +++ b/tests/phpunit/misc/test_FrmMisc.php @@ -11,8 +11,8 @@ class test_FrmMisc extends FrmUnitTest { public function test_load_formidable_forms() { global $frm_vars; $this->assertNotEmpty( $frm_vars ); - $this->assertArrayHasKey('load_css', $frm_vars); - $this->assertArrayHasKey('pro_is_authorized', $frm_vars); + $this->assertArrayHasKey( 'load_css', $frm_vars ); + $this->assertArrayHasKey( 'pro_is_authorized', $frm_vars ); $this->assertSame( 0, has_action( 'init', 'FrmAppController::load_lang' ) ); } diff --git a/tests/phpunit/styles/test_FrmStylesHelper.php b/tests/phpunit/styles/test_FrmStylesHelper.php index 4e8bbc5f0f..fcca2156ba 100644 --- a/tests/phpunit/styles/test_FrmStylesHelper.php +++ b/tests/phpunit/styles/test_FrmStylesHelper.php @@ -10,7 +10,7 @@ class test_FrmStylesHelper extends FrmUnitTest { */ public function test_get_upload_base() { $base = FrmStylesHelper::get_upload_base(); - $this->assertArrayHasKey('baseurl', $base); + $this->assertArrayHasKey( 'baseurl', $base ); $this->assertStringContainsString( 'http://', $base['baseurl'] ); $_SERVER['HTTPS'] = 'on';