diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index a42d6474ef..e08bd6aed2 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -19,4 +19,4 @@ jobs: run: composer install --dev --prefer-dist --no-progress - name: PHPCSFixer check - run: ./vendor/bin/php-cs-fixer fix --dry-run --verbose + run: ./vendor/bin/php-cs-fixer fix --dry-run --allow-risky=yes --verbose diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 8a46cdb28e..64ea29997f 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -37,9 +37,14 @@ 'phpdoc_types_order' => array( 'null_adjustment' => 'always_last', ), + PhpCsFixerCustomFixers\Fixer\PhpUnitAssertArgumentsOrderFixer::name() => true, + PhpCsFixerCustomFixers\Fixer\PhpUnitDedicatedAssertFixer::name() => true, + PhpCsFixerCustomFixers\Fixer\NoUselessStrlenFixer::name() => true, + PhpCsFixerCustomFixers\Fixer\NoUselessParenthesisFixer::name() => true, ); $config = new PhpCsFixer\Config(); +$config->registerCustomFixers(new PhpCsFixerCustomFixers\Fixers()); $config->setRules( $rules ); return $config->setFinder( $finder ); diff --git a/classes/helpers/FrmAppHelper.php b/classes/helpers/FrmAppHelper.php index a0e6546714..57ded23530 100644 --- a/classes/helpers/FrmAppHelper.php +++ b/classes/helpers/FrmAppHelper.php @@ -3413,7 +3413,7 @@ private static function get_time_strings() { * @return int */ public static function get_last_record_num( $r_count, $current_p, $p_size ) { - return ( $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size ); + return $r_count < $current_p * $p_size ? $r_count : $current_p * $p_size; } /** diff --git a/composer.json b/composer.json index c61d6e6641..afe67d4359 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,8 @@ "slevomat/coding-standard": "~8.0", "friendsofphp/php-cs-fixer": "^3.54", "rector/rector": "^2.3.4", - "phpstan/phpstan-strict-rules": "^2.0" + "phpstan/phpstan-strict-rules": "^2.0", + "kubawerlos/php-cs-fixer-custom-fixers": "^3.36" }, "config": { "allow-plugins": { diff --git a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnAssignedVariableSniff.php b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnAssignedVariableSniff.php index 6aa5c280a0..0fb6bde5f8 100644 --- a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnAssignedVariableSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnAssignedVariableSniff.php @@ -100,7 +100,7 @@ public function process( File $phpcsFile, $stackPtr ) { // Check if there's a boolean NOT before empty. $prevToken = $phpcsFile->findPrevious( T_WHITESPACE, $stackPtr - 1, null, true ); - $isNegated = ( false !== $prevToken && $tokens[ $prevToken ]['code'] === T_BOOLEAN_NOT ); + $isNegated = false !== $prevToken && $tokens[ $prevToken ]['code'] === T_BOOLEAN_NOT; // Determine the suggested replacement. if ( $isNegated ) { diff --git a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnParameterSniff.php b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnParameterSniff.php index 84dbdb0073..27456c1e8b 100644 --- a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnParameterSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantEmptyOnParameterSniff.php @@ -99,7 +99,7 @@ public function process( File $phpcsFile, $stackPtr ) { // Check if there's a boolean NOT before empty. $prevToken = $phpcsFile->findPrevious( T_WHITESPACE, $stackPtr - 1, null, true ); - $isNegated = ( false !== $prevToken && $tokens[ $prevToken ]['code'] === T_BOOLEAN_NOT ); + $isNegated = false !== $prevToken && $tokens[ $prevToken ]['code'] === T_BOOLEAN_NOT; // Determine the suggested replacement. if ( $isNegated ) { diff --git a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantIconEchoArgSniff.php b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantIconEchoArgSniff.php index 8da09ecc96..530ef972b1 100644 --- a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantIconEchoArgSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/RedundantIconEchoArgSniff.php @@ -148,11 +148,11 @@ private function findEchoTrueArg( File $phpcsFile, $openParen, $closeParen ) { // Look for leading comma (this arg comes after another). $beforeStart = $phpcsFile->findPrevious( T_WHITESPACE, $i - 1, $openParen, true ); - $hasLeadingComma = ( false !== $beforeStart && $tokens[ $beforeStart ]['code'] === T_COMMA ); + $hasLeadingComma = false !== $beforeStart && $tokens[ $beforeStart ]['code'] === T_COMMA; // Look for trailing comma. $afterEnd = $phpcsFile->findNext( T_WHITESPACE, $value + 1, $closeParen, true ); - $hasTrailingComma = ( false !== $afterEnd && $tokens[ $afterEnd ]['code'] === T_COMMA ); + $hasTrailingComma = false !== $afterEnd && $tokens[ $afterEnd ]['code'] === T_COMMA; if ( $hasLeadingComma ) { // Include the leading comma and whitespace. diff --git a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php index 2c2134f5fc..1042529c42 100644 --- a/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/CodeAnalysis/UpdateOptionAutoloadBooleanSniff.php @@ -145,7 +145,7 @@ private function getFunctionArguments( File $phpcsFile, $openParen ) { $level--; } - $nextIsSeparator = ( $code === T_COMMA && 0 === $level ); + $nextIsSeparator = $code === T_COMMA && 0 === $level; if ( false === $argStart ) { continue; diff --git a/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingDocblockSniff.php b/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingDocblockSniff.php index bb3e65816c..7918110f20 100644 --- a/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingDocblockSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingDocblockSniff.php @@ -119,7 +119,7 @@ private function processMissingAnnotations( File $phpcsFile, $stackPtr, $docbloc } // Check for missing @return tag. - $missingReturn = ( ! $hasReturnTag && null !== $returnType ); + $missingReturn = ! $hasReturnTag && null !== $returnType; if ( empty( $missingParams ) && ! $missingReturn ) { return; diff --git a/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingParamTypeFromCallsSniff.php b/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingParamTypeFromCallsSniff.php index d0ee8a4bcd..149fcd2760 100644 --- a/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingParamTypeFromCallsSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/Commenting/AddMissingParamTypeFromCallsSniff.php @@ -77,7 +77,7 @@ public function process( File $phpcsFile, $stackPtr ) { // Check if function has a docblock. $docblock = $this->findDocblock( $phpcsFile, $stackPtr ); - $hasDocblock = ( false !== $docblock ); + $hasDocblock = false !== $docblock; $existingParams = array(); if ( $hasDocblock ) { diff --git a/phpcs-sniffs/Formidable/Sniffs/PHPUnit/PreferAssertStringContainsSniff.php b/phpcs-sniffs/Formidable/Sniffs/PHPUnit/PreferAssertStringContainsSniff.php index 77783f7833..e8a588dcbe 100644 --- a/phpcs-sniffs/Formidable/Sniffs/PHPUnit/PreferAssertStringContainsSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/PHPUnit/PreferAssertStringContainsSniff.php @@ -157,7 +157,7 @@ public function process( File $phpcsFile, $stackPtr ) { // assertFalse(str_contains()) -> assertStringNotContainsString // assertNotFalse(strpos()) -> assertStringContainsString // assertFalse(strpos()) -> assertStringNotContainsString - $wantsContains = ( 'asserttrue' === $methodName || 'assertnotfalse' === $methodName ); + $wantsContains = 'asserttrue' === $methodName || 'assertnotfalse' === $methodName; // Negation flips the result. if ( $isNegated ) { diff --git a/phpcs-sniffs/Formidable/Sniffs/Security/BreakEchoConcatenationSniff.php b/phpcs-sniffs/Formidable/Sniffs/Security/BreakEchoConcatenationSniff.php index ed45658232..8421c8ef65 100644 --- a/phpcs-sniffs/Formidable/Sniffs/Security/BreakEchoConcatenationSniff.php +++ b/phpcs-sniffs/Formidable/Sniffs/Security/BreakEchoConcatenationSniff.php @@ -161,7 +161,7 @@ private function hasConcatenationAroundKses( File $phpcsFile, $stackPtr, $expres } $afterConcat = $phpcsFile->findNext( T_STRING_CONCAT, $closeParen + 1, $semicolon ); - return ( false !== $afterConcat ); + return false !== $afterConcat; } /** @@ -259,7 +259,7 @@ private function fixKsesCall( File $phpcsFile, $stackPtr, $echoPtr, $expressionS $leadingWhitespace = ''; } - $hasLeadingWhitespace = ( '' !== $leadingWhitespace ); + $hasLeadingWhitespace = '' !== $leadingWhitespace; $lineIndent = $indentation; $newLines = array(); diff --git a/tests/phpunit/base/FrmUnitTest.php b/tests/phpunit/base/FrmUnitTest.php index dc1abbcf27..fe6a4bda3f 100644 --- a/tests/phpunit/base/FrmUnitTest.php +++ b/tests/phpunit/base/FrmUnitTest.php @@ -148,7 +148,7 @@ public static function import_xml() { FrmXMLController::add_default_templates(); $form = FrmForm::getOne( 'contact-db12' ); - self::assertEquals( $form->form_key, 'contact-db12' ); + self::assertEquals( 'contact-db12', $form->form_key ); } public static function create_files() { diff --git a/tests/phpunit/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index 8aaf52476e..84f9915aba 100644 --- a/tests/phpunit/database/test_FrmMigrate.php +++ b/tests/phpunit/database/test_FrmMigrate.php @@ -31,7 +31,7 @@ public function test_maybe_create_contact_form() { // Check for auto contact form. $form = FrmForm::getOne( 'contact-form' ); $this->assertNotEmpty( $form ); - $this->assertSame( $form->form_key, 'contact-form' ); + $this->assertSame( 'contact-form', $form->form_key ); // Make sure the form isn't recreated after delete FrmForm::destroy( 'contact-form' ); @@ -363,7 +363,7 @@ public function test_migrate_from_12_to_current() { $this->assertTrue( ! isset( $form->options['notification'] ), 'The migrated notification settings are not cleared from form.' ); - $this->assertSame( 1, count( $form_actions ), 'Old form settings are not converted to email action.' ); + $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'] ); diff --git a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php index aa3f153a7b..667a19acc9 100644 --- a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php +++ b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php @@ -25,7 +25,7 @@ public function test_get_date_obj() { ); $this->assertTrue( $date instanceof DateTime ); - $this->assertSame( $date->format( 'Y-m-d' ), '2023-08-13' ); + $this->assertSame( '2023-08-13', $date->format( 'Y-m-d' ) ); $this->assertFalse( $this->run_private_method( @@ -37,11 +37,11 @@ public function test_get_date_obj() { public function test_get_date_diff() { $this->assertSame( + 4, $this->run_private_method( array( 'FrmEmailSummaryHelper', 'get_date_diff' ), array( '2023-08-12', '2023-08-16' ) - ), - 4 + ) ); $this->assertFalse( diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php index 85bf171593..e029bd98f0 100644 --- a/tests/phpunit/entries/test_FrmEntryValidate.php +++ b/tests/phpunit/entries/test_FrmEntryValidate.php @@ -188,12 +188,12 @@ public function test_get_all_form_ids_and_flatten_meta() { array( &$test_values ) ); - $this->assertEquals( $form_ids, array( 1, 17, 11 ) ); + $this->assertEquals( array( 1, 17, 11 ), $form_ids ); $this->assertFalse( isset( $test_values['item_meta'][163] ) ); $this->assertFalse( isset( $test_values['item_meta'][165] ) ); - $this->assertEquals( $test_values['item_meta'][162], array( 'Option 2', 'Option 1' ) ); - $this->assertEquals( $test_values['item_meta'][118], array( 'John Doe' ) ); - $this->assertSame( $test_values['item_meta'][1], 'John Doe' ); + $this->assertEquals( array( 'Option 2', 'Option 1' ), $test_values['item_meta'][162] ); + $this->assertEquals( array( 'John Doe' ), $test_values['item_meta'][118] ); + $this->assertSame( 'John Doe', $test_values['item_meta'][1] ); } public function test_skip_adding_values_to_akismet() { diff --git a/tests/phpunit/entries/test_FrmTableHTMLGenerator.php b/tests/phpunit/entries/test_FrmTableHTMLGenerator.php index fa3b15128f..fe9358e6b9 100644 --- a/tests/phpunit/entries/test_FrmTableHTMLGenerator.php +++ b/tests/phpunit/entries/test_FrmTableHTMLGenerator.php @@ -53,7 +53,7 @@ public function test_remove_border() { ); $html = '
'; - $this->assertSame( $table_generator->remove_border( $html ), '' ); + $this->assertSame( '', $table_generator->remove_border( $html ) ); $this->assertEquals( $table_generator->remove_border( $html, 'bottom' ), $html ); $html = ''; diff --git a/tests/phpunit/fields/test_FrmField.php b/tests/phpunit/fields/test_FrmField.php index 7ac580a923..67afbdb7b5 100644 --- a/tests/phpunit/fields/test_FrmField.php +++ b/tests/phpunit/fields/test_FrmField.php @@ -40,7 +40,7 @@ public function test_getAll() { $form_id = $this->factory->form->get_id_by_key( $form_key ); $fields = FrmField::getAll( array( 'fi.form_id' => (int) $form_id ) ); $this->assertNotEmpty( $fields ); - $this->assertEquals( $expected_count, count( $fields ), 'An incorrect number of fields are retrieved with FrmField::getAll.' ); + $this->assertCount( $expected_count, $fields, 'An incorrect number of fields are retrieved with FrmField::getAll.' ); } } @@ -69,7 +69,7 @@ public function test_get_all_for_form() { } $this->assertNotEmpty( $fields ); - $this->assertEquals( $args['count'], count( $fields ), 'An incorrect number of fields are retrieved with FrmField::get_all_for_form for ' . $test . '.' ); + $this->assertCount( $args['count'], $fields, 'An incorrect number of fields are retrieved with FrmField::get_all_for_form for ' . $test . '.' ); } } } diff --git a/tests/phpunit/fields/test_FrmFieldCombo.php b/tests/phpunit/fields/test_FrmFieldCombo.php index c0f97e95dd..045feb694b 100644 --- a/tests/phpunit/fields/test_FrmFieldCombo.php +++ b/tests/phpunit/fields/test_FrmFieldCombo.php @@ -83,7 +83,7 @@ protected function get_combo_field_with_sub_field_options() { public function test_register_sub_fields() { $combo_field = new FrmFieldCombo(); - $this->assertEquals( $this->get_private_property( $combo_field, 'sub_fields' ), array() ); + $this->assertEquals( array(), $this->get_private_property( $combo_field, 'sub_fields' ) ); $this->run_private_method( array( $combo_field, 'register_sub_fields' ), @@ -96,7 +96,6 @@ public function test_register_sub_fields() { ); $this->assertEquals( - $this->get_private_property( $combo_field, 'sub_fields' ), array( 'first' => array( 'name' => 'first', @@ -126,7 +125,8 @@ public function test_register_sub_fields() { ), 'atts' => array(), ), - ) + ), + $this->get_private_property( $combo_field, 'sub_fields' ) ); $this->set_private_property( $combo_field, 'sub_fields', array() ); @@ -147,7 +147,6 @@ public function test_register_sub_fields() { ); $this->assertEquals( - $this->get_private_property( $combo_field, 'sub_fields' ), array( 'second' => array( 'name' => 'second', @@ -173,25 +172,26 @@ public function test_register_sub_fields() { 'options' => array(), 'atts' => array(), ), - ) + ), + $this->get_private_property( $combo_field, 'sub_fields' ) ); } public function test_extra_field_opts() { $combo_field = $this->get_combo_field_without_sub_field_options(); - $this->assertEquals( $this->run_private_method( array( $combo_field, 'extra_field_opts' ) ), array() ); + $this->assertEquals( array(), $this->run_private_method( array( $combo_field, 'extra_field_opts' ) ) ); $combo_field = $this->get_combo_field_with_sub_field_options(); $this->assertEquals( - $this->run_private_method( array( $combo_field, 'extra_field_opts' ) ), array( 'name_desc' => '', 'email_placeholder' => '', 'dob_desc' => '', 'dob_custom_opt' => '', - ) + ), + $this->run_private_method( array( $combo_field, 'extra_field_opts' ) ) ); } @@ -199,24 +199,24 @@ public function test_get_default_value() { $combo_field = $this->get_combo_field_without_sub_field_options(); $this->assertEquals( - $this->run_private_method( array( $combo_field, 'get_default_value' ) ), array( 'first_child' => '', 'second_child' => '', 'third_child' => '', 'forth_child' => '', - ) + ), + $this->run_private_method( array( $combo_field, 'get_default_value' ) ) ); $combo_field = $this->get_combo_field_with_sub_field_options(); $this->assertEquals( - $this->run_private_method( array( $combo_field, 'get_default_value' ) ), array( 'name' => '', 'email' => '', 'dob' => '', - ) + ), + $this->run_private_method( array( $combo_field, 'get_default_value' ) ) ); } @@ -262,7 +262,7 @@ public function test_print_input_atts() { ); $atts = ob_get_clean(); - $this->assertSame( $atts, ' placeholder="First placeholder" class="frm-custom-class" maxlength="10" data-attr="custom-attr" ' ); + $this->assertSame( ' placeholder="First placeholder" class="frm-custom-class" maxlength="10" data-attr="custom-attr" ', $atts ); $sub_field = array( 'name' => 'second', @@ -283,7 +283,7 @@ public function test_print_input_atts() { ); $atts = ob_get_clean(); - $this->assertSame( $atts, ' class="frm-class1 frm-class2 frm_optional" ' ); + $this->assertSame( ' class="frm-class1 frm-class2 frm_optional" ', $atts ); $sub_field = array( 'name' => 'forth', @@ -299,7 +299,7 @@ public function test_print_input_atts() { ); $atts = ob_get_clean(); - $this->assertSame( $atts, ' ' ); + $this->assertSame( ' ', $atts ); } public function test_get_export_headings() { diff --git a/tests/phpunit/fields/test_FrmFieldType.php b/tests/phpunit/fields/test_FrmFieldType.php index 416a41fb7c..892d6b852b 100644 --- a/tests/phpunit/fields/test_FrmFieldType.php +++ b/tests/phpunit/fields/test_FrmFieldType.php @@ -198,9 +198,9 @@ public function test_get_import_value() { $checkbox = FrmFieldFactory::get_field_type( 'checkbox', $field ); - $this->assertSame( $checkbox->get_import_value( 'a,b' ), 'a,b' ); - $this->assertEquals( $checkbox->get_import_value( 'a,c' ), array( 'a', 'c' ) ); - $this->assertSame( $checkbox->get_import_value( 'a,b,c' ), 'a,b,c' ); + $this->assertSame( 'a,b', $checkbox->get_import_value( 'a,b' ) ); + $this->assertEquals( array( 'a', 'c' ), $checkbox->get_import_value( 'a,c' ) ); + $this->assertSame( 'a,b,c', $checkbox->get_import_value( 'a,b,c' ) ); } /** diff --git a/tests/phpunit/fields/test_FrmSubmitHelper.php b/tests/phpunit/fields/test_FrmSubmitHelper.php index 3480dc2f8b..b80deb7532 100644 --- a/tests/phpunit/fields/test_FrmSubmitHelper.php +++ b/tests/phpunit/fields/test_FrmSubmitHelper.php @@ -15,7 +15,7 @@ public function test_copy_submit_field_settings_to_form() { ); $new_form = FrmSubmitHelper::copy_submit_field_settings_to_form( $form ); - $this->assertSame( $new_form->options['submit_value'], 'Submit form' ); + $this->assertSame( 'Submit form', $new_form->options['submit_value'] ); } public function test_only_contains_submit_field() { diff --git a/tests/phpunit/forms/test_FrmForm.php b/tests/phpunit/forms/test_FrmForm.php index bf332f8744..82e47a7aba 100644 --- a/tests/phpunit/forms/test_FrmForm.php +++ b/tests/phpunit/forms/test_FrmForm.php @@ -32,7 +32,7 @@ public function test_duplicate() { // Check the number of form actions $original_actions = FrmFormAction::get_action_for_form( $form->id ); $new_actions = FrmFormAction::get_action_for_form( $id ); - $this->assertEquals( count( $original_actions ), count( $new_actions ) ); + $this->assertCount( count( $original_actions ), $new_actions ); } protected function _check_if_child_fields_duplicate( $old_child_forms, $new_child_forms ) { @@ -45,7 +45,7 @@ protected function _check_if_child_fields_duplicate( $old_child_forms, $new_chil $new_child_form_fields = FrmField::get_all_for_form( $new_child_form->id ); // Check if there are the same number of child form fields in the duplicated child form - $this->assertEquals( count( $old_child_form_fields ), count( $new_child_form_fields ), 'When a form is duplicated, the fields in the repeating section are not duplicated correctly.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong + $this->assertCount( count( $old_child_form_fields ), $new_child_form_fields, 'When a form is duplicated, the fields in the repeating section are not duplicated correctly.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong } /** diff --git a/tests/phpunit/forms/test_FrmFormsController.php b/tests/phpunit/forms/test_FrmFormsController.php index 6a1c89803a..ff41def4ec 100644 --- a/tests/phpunit/forms/test_FrmFormsController.php +++ b/tests/phpunit/forms/test_FrmFormsController.php @@ -324,7 +324,7 @@ public function run_message_after_create( $show_form = 0 ) { ); // Test default action. - $this->assertEquals( $form->options['success_action'], 'message' ); + $this->assertEquals( 'message', $form->options['success_action'] ); $this->create_on_submit_action( $form->id, diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index 074673081a..736ddb5fa3 100644 --- a/tests/phpunit/misc/test_FrmAppHelper.php +++ b/tests/phpunit/misc/test_FrmAppHelper.php @@ -46,7 +46,7 @@ public function test_plugin_path() { */ public function test_relative_plugin_url() { $path = FrmAppHelper::relative_plugin_url(); - $this->assertSame( strpos( $path, '/' ), 0 ); + $this->assertSame( 0, strpos( $path, '/' ) ); } /** @@ -171,11 +171,11 @@ public function test_is_empty_value() { */ public function test_get_server_value() { $url = FrmAppHelper::get_server_value( 'HTTP_HOST' ); - $this->assertSame( $url, 'example.org' ); + $this->assertSame( 'example.org', $url ); $_SERVER['HTTP_HOST'] = 'example.org'; $url = FrmAppHelper::get_server_value( 'HTTP_HOST' ); - $this->assertSame( $url, 'example.org' ); + $this->assertSame( 'example.org', $url ); } /** @@ -308,7 +308,7 @@ public function test_kses() { $safe_value = 'Hello, click here'; $start_value .= $safe_value; $stripped_value = FrmAppHelper::kses( $start_value ); - $this->assertSame( $stripped_value, 'Hello, click here' ); + $this->assertSame( 'Hello, click here', $stripped_value ); $stripped_value = FrmAppHelper::kses( $start_value, array( 'a' ) ); $this->assertEquals( $stripped_value, $safe_value ); diff --git a/tests/phpunit/misc/test_FrmSpamCheckDenylist.php b/tests/phpunit/misc/test_FrmSpamCheckDenylist.php index 7107cae9eb..2e314855c2 100644 --- a/tests/phpunit/misc/test_FrmSpamCheckDenylist.php +++ b/tests/phpunit/misc/test_FrmSpamCheckDenylist.php @@ -152,13 +152,13 @@ public function test_get_values_to_check() { array( $this->custom_denylist_data['denylist_with_all_fields'] ) ); $this->assertEquals( - $values_to_check, array( 'test@gmail.com', 'this text contains test@domain.com', 'WordPress Plugin', 'john@doe.com', - ) + ), + $values_to_check ); $values_to_check = $this->run_private_method( @@ -166,13 +166,13 @@ public function test_get_values_to_check() { array( $this->custom_denylist_data['denylist_with_name_text_email'] ) ); $this->assertEquals( - $values_to_check, array( 'test@gmail.com', 'this text contains test@domain.com', 'WordPress Plugin', 'john@doe.com', - ) + ), + $values_to_check ); $values_to_check = $this->run_private_method( @@ -180,10 +180,10 @@ public function test_get_values_to_check() { array( $this->custom_denylist_data['denylist_with_name'] ) ); $this->assertEquals( - $values_to_check, array( 'WordPress Plugin', - ) + ), + $values_to_check ); $values_to_check = $this->run_private_method( @@ -191,12 +191,12 @@ public function test_get_values_to_check() { array( $this->custom_denylist_data['denylist_with_extract_email'] ) ); $this->assertEquals( - $values_to_check, array( 'test@gmail.com', 'test@domain.com', 'john@doe.com', - ) + ), + $values_to_check ); $values_to_check = $this->run_private_method( @@ -204,11 +204,11 @@ public function test_get_values_to_check() { array( $this->custom_denylist_data['denylist_with_email'] ) ); $this->assertEquals( - $values_to_check, array( 'test@gmail.com', 'john@doe.com', - ) + ), + $values_to_check ); }