diff --git a/classes/helpers/FrmFormsHelper.php b/classes/helpers/FrmFormsHelper.php index c5d89265f0..37d7b4f3a2 100644 --- a/classes/helpers/FrmFormsHelper.php +++ b/classes/helpers/FrmFormsHelper.php @@ -1105,7 +1105,7 @@ private static function field_has_top_label( $field, $form ) { /** * @param array|bool|int|object|string $form * - * @return string + * @return int|string */ public static function get_form_style( $form ) { $style = 1; diff --git a/mago.toml b/mago.toml index da39b0ce79..ac021679c4 100644 --- a/mago.toml +++ b/mago.toml @@ -25,7 +25,7 @@ preset = "default" use-tabs = true [linter] -integrations = [] +integrations = [ "wordpress", "phpunit" ] [linter.rules] ambiguous-function-call = { enabled = false } @@ -64,6 +64,14 @@ tagged-todo = { enabled = false } too-many-methods = { enabled = false } too-many-properties = { enabled = false } use-compound-assignment = { enabled = false } # Consider enabling this soon. +# PHPUnit Rules +assertion-style = { enabled = false } +# WordPress Rules +no-db-schema-change = { enabled = false } +no-direct-db-query = { enabled = false } +no-roles-as-capabilities = { enabled = false } +no-unescaped-output = { enabled = false } +use-wp-functions = { enabled = false } [analyzer] plugins = [] diff --git a/tests/phpunit/applications/test_FrmApplicationApi.php b/tests/phpunit/applications/test_FrmApplicationApi.php index 5fce29ff20..38fd8cc397 100644 --- a/tests/phpunit/applications/test_FrmApplicationApi.php +++ b/tests/phpunit/applications/test_FrmApplicationApi.php @@ -23,7 +23,7 @@ public function test_get_api_info() { $business_hours = $applications[ $business_hours_id ]; $this->assertIsArray( $business_hours ); - $this->assertEquals( 'business-hours-template', $business_hours['slug'] ); + $this->assertSame( 'business-hours-template', $business_hours['slug'] ); $this->assertArrayHasKey( 'name', $business_hours ); $this->assertNotEmpty( $business_hours['name'] ); } diff --git a/tests/phpunit/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index 5452054082..8aaf52476e 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->assertEquals( $form->form_key, 'contact-form' ); + $this->assertSame( $form->form_key, 'contact-form' ); // 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->assertEquals( 1, count( $form_actions ), 'Old form settings are not converted to email action.' ); + $this->assertSame( 1, count( $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_FrmEmail.php b/tests/phpunit/emails/test_FrmEmail.php index 12e2f51f68..ae6aa3e19a 100644 --- a/tests/phpunit/emails/test_FrmEmail.php +++ b/tests/phpunit/emails/test_FrmEmail.php @@ -595,7 +595,7 @@ public function test_set_reply_to() { $action->post_content['reply_to'] = '[' . $email_field_key . ']'; $email = new FrmEmail( $action, $entry, $this->contact_form ); $actual = $this->get_private_property( $email, 'reply_to' ); - $this->assertEquals( 'fromemail@example.com', $actual ); + $this->assertSame( 'fromemail@example.com', $actual ); } /** diff --git a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php index bf1ef543ee..aa3f153a7b 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->assertEquals( $date->format( 'Y-m-d' ), '2023-08-13' ); + $this->assertSame( $date->format( 'Y-m-d' ), '2023-08-13' ); $this->assertFalse( $this->run_private_method( @@ -36,7 +36,7 @@ public function test_get_date_obj() { } public function test_get_date_diff() { - $this->assertEquals( + $this->assertSame( $this->run_private_method( array( 'FrmEmailSummaryHelper', 'get_date_diff' ), array( '2023-08-12', '2023-08-16' ) @@ -175,10 +175,10 @@ function ( $pre, $parsed_args, $url ) { $recipients = 'test@example.com'; FrmEmailSummaryHelper::maybe_remove_recipients_from_api( $recipients ); - $this->assertEquals( '', $recipients ); + $this->assertSame( '', $recipients ); $recipients = 'test@example.com,recipient2@example.com'; FrmEmailSummaryHelper::maybe_remove_recipients_from_api( $recipients ); - $this->assertEquals( 'recipient2@example.com', $recipients ); + $this->assertSame( 'recipient2@example.com', $recipients ); } } diff --git a/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php b/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php index 5d0e9030bb..9a3346e212 100644 --- a/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php +++ b/tests/phpunit/entries/test_FrmEntriesAJAXSubmitController.php @@ -30,7 +30,7 @@ public function test_maybe_modify_ajax_error() { ), ) ); - $this->assertEquals( + $this->assertSame( '
My custom error label: This field cannot be blank.
', $this->maybe_modify_ajax_error( $error, $field_id, $form ) ); diff --git a/tests/phpunit/entries/test_FrmEntriesController.php b/tests/phpunit/entries/test_FrmEntriesController.php index 82f7a03a3d..9773cb0c44 100644 --- a/tests/phpunit/entries/test_FrmEntriesController.php +++ b/tests/phpunit/entries/test_FrmEntriesController.php @@ -20,7 +20,7 @@ public function test_delete_entry_after_save() { $post = get_post( $post_id ); $this->assertNotEmpty( $post ); - $this->assertEquals( 'publish', $post->post_status ); + $this->assertSame( 'publish', $post->post_status ); $no_save_form = $this->create_form( array( 'no_save' => 1 ) ); $this->assertNotEmpty( $no_save_form->options['no_save'] ); @@ -31,7 +31,7 @@ public function test_delete_entry_after_save() { $post = get_post( $created_post ); $this->assertNotEmpty( $post ); - $this->assertEquals( 'publish', $post->post_status ); + $this->assertSame( 'publish', $post->post_status ); } /** diff --git a/tests/phpunit/entries/test_FrmEntriesHelper.php b/tests/phpunit/entries/test_FrmEntriesHelper.php index 798acf14c0..0f5d511ba6 100644 --- a/tests/phpunit/entries/test_FrmEntriesHelper.php +++ b/tests/phpunit/entries/test_FrmEntriesHelper.php @@ -19,6 +19,6 @@ public function test_display_value() { $atts = array(); $display_value = FrmEntriesHelper::display_value( $value, $field, $atts ); $this->assertIsString( $display_value ); - $this->assertEquals( 'Option 1, Option 2', $display_value ); + $this->assertSame( 'Option 1, Option 2', $display_value ); } } diff --git a/tests/phpunit/entries/test_FrmEntriesListHelper.php b/tests/phpunit/entries/test_FrmEntriesListHelper.php index e36e7aa07e..248f56a561 100644 --- a/tests/phpunit/entries/test_FrmEntriesListHelper.php +++ b/tests/phpunit/entries/test_FrmEntriesListHelper.php @@ -34,13 +34,13 @@ public function test_column_value() { $column_value = $this->column_value( $item, 'description' ); $this->assertIsString( $column_value ); - $this->assertEquals( 'Description field value', $column_value ); + $this->assertSame( 'Description field value', $column_value ); $column_value = $this->column_value( $item, 'id' ); - $this->assertEquals( 1, $column_value ); + $this->assertSame( 1, $column_value ); $column_value = $this->column_value( $item, 'name' ); - $this->assertEquals( 'My entry name', $column_value ); + $this->assertSame( 'My entry name', $column_value ); } /** diff --git a/tests/phpunit/entries/test_FrmEntryFormatter.php b/tests/phpunit/entries/test_FrmEntryFormatter.php index 8ed12e6738..03163db35f 100644 --- a/tests/phpunit/entries/test_FrmEntryFormatter.php +++ b/tests/phpunit/entries/test_FrmEntryFormatter.php @@ -21,11 +21,11 @@ public function test_flatten_array() { ); $this->formatter = new FrmEntryFormatter( $atts ); - $this->assertEquals( 'Option 1, Option 2, Option 3', $this->flatten_array( $values ) ); + $this->assertSame( 'Option 1, Option 2, Option 3', $this->flatten_array( $values ) ); $atts['array_separator'] = '
'; $this->formatter = new FrmEntryFormatter( $atts ); - $this->assertEquals( 'Option 1
Option 2
Option 3', $this->flatten_array( $values ) ); + $this->assertSame( 'Option 1
Option 2
Option 3', $this->flatten_array( $values ) ); } private function flatten_array( $value ) { diff --git a/tests/phpunit/entries/test_FrmEntryMeta.php b/tests/phpunit/entries/test_FrmEntryMeta.php index f802402357..a93fa5749f 100644 --- a/tests/phpunit/entries/test_FrmEntryMeta.php +++ b/tests/phpunit/entries/test_FrmEntryMeta.php @@ -29,7 +29,7 @@ public function test_update_entry_metas() { $meta = FrmEntryMeta::get_entry_meta_by_field( $entry_id, $field_id ); - $this->assertEquals( 'Updated value by field ID', $meta ); + $this->assertSame( 'Updated value by field ID', $meta ); // Test field key. $field_key = FrmField::get_key_by_id( $field_id ); @@ -40,7 +40,7 @@ public function test_update_entry_metas() { $meta = FrmEntryMeta::get_entry_meta_by_field( $entry_id, $field_id ); - $this->assertEquals( 'Updated value by field key', $meta ); + $this->assertSame( 'Updated value by field key', $meta ); // Test with an empty value. It should be null because the row should be deleted from the db. $values = array( @@ -59,11 +59,11 @@ public function test_update_entry_metas() { public function test_should_join_fields_table() { $where = 'fi.form_id=123'; $this->assertFalse( $this->run_private_method( array( 'FrmEntryMeta', 'should_join_fields_table' ), array( &$where ) ) ); - $this->assertEquals( 'e.form_id=123', $where ); + $this->assertSame( 'e.form_id=123', $where ); $where = 'fi.id=123 AND fi.form_id=456'; $this->assertTrue( $this->run_private_method( array( 'FrmEntryMeta', 'should_join_fields_table' ), array( &$where ) ) ); - $this->assertEquals( 'fi.id=123 AND fi.form_id=456', $where ); + $this->assertSame( 'fi.id=123 AND fi.form_id=456', $where ); $where = array( 'fi.id' => 123, diff --git a/tests/phpunit/entries/test_FrmEntryValidate.php b/tests/phpunit/entries/test_FrmEntryValidate.php index 985f6e6c46..85bf171593 100644 --- a/tests/phpunit/entries/test_FrmEntryValidate.php +++ b/tests/phpunit/entries/test_FrmEntryValidate.php @@ -25,7 +25,7 @@ public function test_validate() { $this->assertIsArray( $errors ); $this->assertArrayHasKey( 'custom_error', $errors ); - $this->assertEquals( 'Error message', $errors['custom_error'] ); + $this->assertSame( 'Error message', $errors['custom_error'] ); remove_filter( 'frm_validate_entry', $add_a_custom_error ); } @@ -58,7 +58,7 @@ public function test_get_spam_check_user_info() { $check = $this->get_spam_check_user_info( $values ); $this->assertTrue( empty( $check['user_ID'] ) ); $this->assertTrue( empty( $check['user_id'] ) ); - $this->assertEquals( 'Some Guy', $check['comment_author'] ); + $this->assertSame( 'Some Guy', $check['comment_author'] ); $this->assertEquals( $test_email, $check['comment_author_email'] ); $this->assertEquals( $test_url, $check['comment_author_url'] ); @@ -92,7 +92,7 @@ public function test_get_spam_check_user_info() { $_POST['form_id'] = $form_id; $this->run_private_method( array( 'FrmEntryValidate', 'prepare_values_for_spam_check' ), array( &$values ) ); $check = $this->get_spam_check_user_info( $values ); - $this->assertEquals( 'John Doe', $check['comment_author'] ); + $this->assertSame( 'John Doe', $check['comment_author'] ); // Test with repeater/embedded field. $values['item_meta'][ $made_up_name_field_id ] = array( @@ -109,9 +109,9 @@ public function test_get_spam_check_user_info() { ); $check = $this->get_spam_check_user_info( $values ); - $this->assertEquals( 'John Doe', $check['comment_author'] ); - $this->assertEquals( 'johndoe@gmail.com', $check['comment_author_email'] ); - $this->assertEquals( 'https://johndoe.com', $check['comment_author_url'] ); + $this->assertSame( 'John Doe', $check['comment_author'] ); + $this->assertSame( 'johndoe@gmail.com', $check['comment_author_email'] ); + $this->assertSame( 'https://johndoe.com', $check['comment_author_url'] ); wp_set_current_user( 1 ); $user = wp_get_current_user(); @@ -193,7 +193,7 @@ public function test_get_all_form_ids_and_flatten_meta() { $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->assertEquals( $test_values['item_meta'][1], 'John Doe' ); + $this->assertSame( $test_values['item_meta'][1], 'John Doe' ); } public function test_skip_adding_values_to_akismet() { diff --git a/tests/phpunit/entries/test_FrmShortodeHelper.php b/tests/phpunit/entries/test_FrmShortodeHelper.php index 357153c1f1..290792fa66 100644 --- a/tests/phpunit/entries/test_FrmShortodeHelper.php +++ b/tests/phpunit/entries/test_FrmShortodeHelper.php @@ -48,7 +48,7 @@ public function test_get_shortcode_tag() { $this->assertNotEmpty( $matches[0][0] ); $tag = FrmShortcodeHelper::get_shortcode_tag( $matches, 0, $args ); - $this->assertEquals( '25', $tag ); + $this->assertSame( '25', $tag ); } } diff --git a/tests/phpunit/entries/test_FrmTableHTMLGenerator.php b/tests/phpunit/entries/test_FrmTableHTMLGenerator.php index 7bfa0d0568..fa3b15128f 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->assertEquals( $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_FrmFieldCombo.php b/tests/phpunit/fields/test_FrmFieldCombo.php index 00ab9ac404..c0f97e95dd 100644 --- a/tests/phpunit/fields/test_FrmFieldCombo.php +++ b/tests/phpunit/fields/test_FrmFieldCombo.php @@ -262,7 +262,7 @@ public function test_print_input_atts() { ); $atts = ob_get_clean(); - $this->assertEquals( $atts, ' placeholder="First placeholder" class="frm-custom-class" maxlength="10" data-attr="custom-attr" ' ); + $this->assertSame( $atts, ' placeholder="First placeholder" class="frm-custom-class" maxlength="10" data-attr="custom-attr" ' ); $sub_field = array( 'name' => 'second', @@ -283,7 +283,7 @@ public function test_print_input_atts() { ); $atts = ob_get_clean(); - $this->assertEquals( $atts, ' class="frm-class1 frm-class2 frm_optional" ' ); + $this->assertSame( $atts, ' class="frm-class1 frm-class2 frm_optional" ' ); $sub_field = array( 'name' => 'forth', @@ -299,7 +299,7 @@ public function test_print_input_atts() { ); $atts = ob_get_clean(); - $this->assertEquals( $atts, ' ' ); + $this->assertSame( $atts, ' ' ); } public function test_get_export_headings() { diff --git a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php index cdfae8d07d..1c1ea06ef0 100644 --- a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php +++ b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php @@ -15,16 +15,16 @@ class test_FrmFieldGridHelper extends FrmUnitTest { * @covers FrmFieldGridHelper::get_size_of_class */ public function test_get_size_of_class() { - $this->assertEquals( 1, $this->get_size_of_class( 'frm1' ) ); - $this->assertEquals( 6, $this->get_size_of_class( 'frm6' ) ); - $this->assertEquals( 8, $this->get_size_of_class( 'frm8' ) ); - $this->assertEquals( 10, $this->get_size_of_class( 'frm10' ) ); - $this->assertEquals( 12, $this->get_size_of_class( 'frm12' ) ); - $this->assertEquals( 2, $this->get_size_of_class( 'frm_sixth' ) ); - $this->assertEquals( 3, $this->get_size_of_class( 'frm_fourth' ) ); - $this->assertEquals( 4, $this->get_size_of_class( 'frm_third' ) ); - $this->assertEquals( 6, $this->get_size_of_class( 'frm_half' ) ); - $this->assertEquals( 12, $this->get_size_of_class( 'frm_full' ) ); + $this->assertSame( 1, $this->get_size_of_class( 'frm1' ) ); + $this->assertSame( 6, $this->get_size_of_class( 'frm6' ) ); + $this->assertSame( 8, $this->get_size_of_class( 'frm8' ) ); + $this->assertSame( 10, $this->get_size_of_class( 'frm10' ) ); + $this->assertSame( 12, $this->get_size_of_class( 'frm12' ) ); + $this->assertSame( 2, $this->get_size_of_class( 'frm_sixth' ) ); + $this->assertSame( 3, $this->get_size_of_class( 'frm_fourth' ) ); + $this->assertSame( 4, $this->get_size_of_class( 'frm_third' ) ); + $this->assertSame( 6, $this->get_size_of_class( 'frm_half' ) ); + $this->assertSame( 12, $this->get_size_of_class( 'frm_full' ) ); } /** diff --git a/tests/phpunit/fields/test_FrmFieldNumber.php b/tests/phpunit/fields/test_FrmFieldNumber.php index 8269460108..15c632f436 100644 --- a/tests/phpunit/fields/test_FrmFieldNumber.php +++ b/tests/phpunit/fields/test_FrmFieldNumber.php @@ -7,11 +7,11 @@ class test_FrmFieldNumber extends FrmUnitTest { public function test_check_value_is_valid_with_step() { $number_field = new FrmFieldNumber(); - $this->assertEquals( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 9, 3 ) ) ); - $this->assertEquals( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 9.0, 3 ) ) ); - $this->assertEquals( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 9, 3.0 ) ) ); - $this->assertEquals( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 68.93, 0.01 ) ) ); - $this->assertEquals( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( '68.93', '0.01' ) ) ); + $this->assertSame( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 9, 3 ) ) ); + $this->assertSame( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 9.0, 3 ) ) ); + $this->assertSame( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 9, 3.0 ) ) ); + $this->assertSame( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 68.93, 0.01 ) ) ); + $this->assertSame( 0, $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( '68.93', '0.01' ) ) ); $this->assertEquals( array( 0, 3 ), $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 1, 3 ) ) ); $this->assertEquals( array( 8, 10 ), $this->run_private_method( array( $number_field, 'check_value_is_valid_with_step' ), array( 9, 2 ) ) ); diff --git a/tests/phpunit/fields/test_FrmFieldType.php b/tests/phpunit/fields/test_FrmFieldType.php index 90155bc9ce..416a41fb7c 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->assertEquals( $checkbox->get_import_value( 'a,b' ), 'a,b' ); + $this->assertSame( $checkbox->get_import_value( 'a,b' ), 'a,b' ); $this->assertEquals( $checkbox->get_import_value( 'a,c' ), array( 'a', 'c' ) ); - $this->assertEquals( $checkbox->get_import_value( 'a,b,c' ), 'a,b,c' ); + $this->assertSame( $checkbox->get_import_value( 'a,b,c' ), 'a,b,c' ); } /** @@ -315,7 +315,7 @@ public function test_prepare_field_html() { $field_array = FrmFieldsHelper::setup_edit_vars( $field ); $field_object = FrmFieldFactory::get_field_type( 'text', $field_array ); $html = $field_object->prepare_field_html( $args ); - $this->assertEquals( '', $html ); + $this->assertSame( '', $html ); // Test a draft field on a preview page for a privileged user (the HTML should not be empty). $this->reset_should_hide_draft_fields_flag(); diff --git a/tests/phpunit/fields/test_FrmFieldValidate.php b/tests/phpunit/fields/test_FrmFieldValidate.php index d7bb8ca232..0c1428936e 100644 --- a/tests/phpunit/fields/test_FrmFieldValidate.php +++ b/tests/phpunit/fields/test_FrmFieldValidate.php @@ -219,7 +219,7 @@ public function test_number_validation() { ), ) ); - $this->assertEquals( 20, $field->field_options['maxnum'] ); + $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 ) ); @@ -357,7 +357,7 @@ public function test_is_akismet_enabled_for_user() { ), ) ); - $this->assertEquals( 'logged', $akismet_logged->options['akismet'] ); + $this->assertSame( 'logged', $akismet_logged->options['akismet'] ); wp_set_current_user( 0 ); $this->assertFalse( is_user_logged_in() ); diff --git a/tests/phpunit/fields/test_FrmFieldsController.php b/tests/phpunit/fields/test_FrmFieldsController.php index 871c9efde1..1f5c3aca2b 100644 --- a/tests/phpunit/fields/test_FrmFieldsController.php +++ b/tests/phpunit/fields/test_FrmFieldsController.php @@ -20,16 +20,16 @@ public function test_prepare_placeholder() { $placeholder = $this->prepare_placeholder( $field ); // Since Floating labels, placeholder is not replaced by field name anymore. - $this->assertEquals( '', $placeholder ); + $this->assertSame( '', $placeholder ); $field['placeholder'] = '0'; $placeholder = $this->prepare_placeholder( $field ); - $this->assertEquals( '0', $placeholder, '0 is a valid placeholder value.' ); + $this->assertSame( '0', $placeholder, '0 is a valid placeholder value.' ); $field['placeholder'] = ''; $field['type'] = 'hidden'; $placeholder = $this->prepare_placeholder( $field ); - $this->assertEquals( '', $placeholder, 'some types of fields are not "is_placeholder_field_type" and should be left empty.' ); + $this->assertSame( '', $placeholder, 'some types of fields are not "is_placeholder_field_type" and should be left empty.' ); } private function prepare_placeholder( $field ) { @@ -62,7 +62,7 @@ public function test_pull_custom_error_body_from_custom_html() { $field = FrmFieldsHelper::setup_edit_vars( $field ); $error_body = FrmFieldsController::pull_custom_error_body_from_custom_html( $form, $field ); - $this->assertEquals( + $this->assertSame( '
My custom error label: [error]
', $error_body ); @@ -77,18 +77,18 @@ public function test_include_new_field() { $new_field = FrmFieldsController::include_new_field( 'text', $form_id ); $field_output = ob_get_clean(); - $this->assertEquals( 0, strpos( trim( $field_output ), '
  • assertSame( 0, strpos( trim( $field_output ), '
  • assertIsArray( $new_field ); $this->assertArrayHasKey( 'type', $new_field ); - $this->assertEquals( 'text', $new_field['type'] ); + $this->assertSame( 'text', $new_field['type'] ); $this->assertArrayHasKey( 'form_id', $new_field ); $this->assertEquals( $form_id, $new_field['form_id'] ); // Confirm new fields are flagged as "draft". $this->assertArrayHasKey( 'draft', $new_field ); - $this->assertEquals( 1, $new_field['draft'] ); + $this->assertSame( 1, $new_field['draft'] ); } /** diff --git a/tests/phpunit/fields/test_FrmFieldsHelper.php b/tests/phpunit/fields/test_FrmFieldsHelper.php index eeedcb148b..52ba8d7985 100644 --- a/tests/phpunit/fields/test_FrmFieldsHelper.php +++ b/tests/phpunit/fields/test_FrmFieldsHelper.php @@ -260,7 +260,7 @@ public function test_sep_option() { $shortcode = '[' . $checkbox_field->id . ' sep=", "]'; $shortcodes = FrmFieldsHelper::get_shortcodes( $shortcode, $form->id ); - $this->assertEquals( + $this->assertSame( 'Option 1, Option 2', FrmFieldsHelper::replace_content_shortcodes( $shortcode, $entry, $shortcodes ) ); @@ -286,28 +286,28 @@ public function test_get_error_msg() { ); $error_message = FrmFieldsHelper::get_error_msg( $field, 'blank' ); - $this->assertEquals( 'This field cannot be blank', $error_message ); + $this->assertSame( 'This field cannot be blank', $error_message ); $error_message = FrmFieldsHelper::get_error_msg( $field, 'unique_msg' ); - $this->assertEquals( 'This value must be unique', $error_message ); + $this->assertSame( 'This value must be unique', $error_message ); // Test with a field name. $field->name = 'My example field'; $error_message = FrmFieldsHelper::get_error_msg( $field, 'blank' ); - $this->assertEquals( 'My example field cannot be blank', $error_message ); + $this->assertSame( 'My example field cannot be blank', $error_message ); $error_message = FrmFieldsHelper::get_error_msg( $field, 'unique_msg' ); - $this->assertEquals( 'My example field must be unique', $error_message ); + $this->assertSame( 'My example field must be unique', $error_message ); // Test that "This field" and "This value" are automatically replaced. $field->field_options['blank'] = 'This field cannot be blank'; $field->field_options['unique_msg'] = 'This value must be unique'; $error_message = FrmFieldsHelper::get_error_msg( $field, 'blank' ); - $this->assertEquals( 'My example field cannot be blank', $error_message ); + $this->assertSame( 'My example field cannot be blank', $error_message ); $error_message = FrmFieldsHelper::get_error_msg( $field, 'unique_msg' ); - $this->assertEquals( 'My example field must be unique', $error_message ); + $this->assertSame( 'My example field must be unique', $error_message ); } } diff --git a/tests/phpunit/fields/test_FrmSubmitHelper.php b/tests/phpunit/fields/test_FrmSubmitHelper.php index 96138ef803..3480dc2f8b 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->assertEquals( $new_form->options['submit_value'], 'Submit form' ); + $this->assertSame( $new_form->options['submit_value'], 'Submit form' ); } public function test_only_contains_submit_field() { diff --git a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php index 82099db55b..e2d16a4630 100644 --- a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php +++ b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php @@ -20,7 +20,7 @@ public function setUp(): void { * @covers FrmFormTemplatesController::menu */ public function test_menu() { - $this->assertEquals( 14, has_action( 'admin_menu', $this->controller . '::menu' ) ); + $this->assertSame( 14, has_action( 'admin_menu', $this->controller . '::menu' ) ); } /** diff --git a/tests/phpunit/forms/test_FrmForm.php b/tests/phpunit/forms/test_FrmForm.php index bb56d7410a..bf332f8744 100644 --- a/tests/phpunit/forms/test_FrmForm.php +++ b/tests/phpunit/forms/test_FrmForm.php @@ -194,14 +194,14 @@ private function sanitize_field_opt( $opt, &$value ) { * @covers FrmForm::normalize_calc_spaces */ public function test_normalize_calc_spaces() { - $this->assertEquals( '5 < 10', $this->normalize_calc_spaces( '5<10' ) ); - $this->assertEquals( '5 < 10', $this->normalize_calc_spaces( '5 <10' ) ); - $this->assertEquals( '5 < 10', $this->normalize_calc_spaces( '5< 10' ) ); - $this->assertEquals( '1 < 2 && 3 < 4 && 5 < 6', $this->normalize_calc_spaces( '1<2 && 3<4 && 5<6' ) ); - $this->assertEquals( '5 <= 10', $this->normalize_calc_spaces( '5<=10' ) ); - $this->assertEquals( '5 <= 10', $this->normalize_calc_spaces( '5 <=10' ) ); - $this->assertEquals( '5 <= 10', $this->normalize_calc_spaces( '5<= 10' ) ); - $this->assertEquals( '1 <= 2 && 3 <= 4 && 5 <= 6', $this->normalize_calc_spaces( '1<=2 && 3<=4 && 5<=6' ) ); + $this->assertSame( '5 < 10', $this->normalize_calc_spaces( '5<10' ) ); + $this->assertSame( '5 < 10', $this->normalize_calc_spaces( '5 <10' ) ); + $this->assertSame( '5 < 10', $this->normalize_calc_spaces( '5< 10' ) ); + $this->assertSame( '1 < 2 && 3 < 4 && 5 < 6', $this->normalize_calc_spaces( '1<2 && 3<4 && 5<6' ) ); + $this->assertSame( '5 <= 10', $this->normalize_calc_spaces( '5<=10' ) ); + $this->assertSame( '5 <= 10', $this->normalize_calc_spaces( '5 <=10' ) ); + $this->assertSame( '5 <= 10', $this->normalize_calc_spaces( '5<= 10' ) ); + $this->assertSame( '1 <= 2 && 3 <= 4 && 5 <= 6', $this->normalize_calc_spaces( '1<=2 && 3<=4 && 5<=6' ) ); } /** diff --git a/tests/phpunit/forms/test_FrmFormsHelper.php b/tests/phpunit/forms/test_FrmFormsHelper.php index c52ce14a65..19ef6df81b 100644 --- a/tests/phpunit/forms/test_FrmFormsHelper.php +++ b/tests/phpunit/forms/test_FrmFormsHelper.php @@ -97,16 +97,16 @@ private function assert_get_plan_required( $expected, $categories ) { */ public function test_get_form_style() { // Test null and 'default' form values. - $this->assertEquals( '1', FrmFormsHelper::get_form_style( null ) ); - $this->assertEquals( '1', FrmFormsHelper::get_form_style( 'default' ) ); + $this->assertSame( 1, FrmFormsHelper::get_form_style( null ) ); + $this->assertSame( 1, FrmFormsHelper::get_form_style( 'default' ) ); // Test object form values. // Test "disable Formidable styling" first. $form = $this->create_form_with_custom_style_value( '0' ); - $this->assertEquals( '0', FrmFormsHelper::get_form_style( $form ) ); + $this->assertSame( '0', FrmFormsHelper::get_form_style( $form ) ); $form = $this->create_form_with_custom_style_value( '' ); - $this->assertEquals( '', FrmFormsHelper::get_form_style( $form ) ); + $this->assertSame( '', FrmFormsHelper::get_form_style( $form ) ); // Create a style and test a custom style value as well. $frm_style = new FrmStyle(); @@ -125,13 +125,13 @@ public function test_get_form_style() { $this->assertEquals( $style_id, FrmFormsHelper::get_form_style( $form ) ); unset( $form['custom_style'] ); - $this->assertEquals( '1', FrmFormsHelper::get_form_style( $form ) ); + $this->assertSame( 1, FrmFormsHelper::get_form_style( $form ) ); $form['custom_style'] = ''; - $this->assertEquals( '', FrmFormsHelper::get_form_style( $form ) ); + $this->assertSame( '', FrmFormsHelper::get_form_style( $form ) ); $form['custom_style'] = '0'; - $this->assertEquals( '0', FrmFormsHelper::get_form_style( $form ) ); + $this->assertSame( '0', FrmFormsHelper::get_form_style( $form ) ); } /** diff --git a/tests/phpunit/helpers/test_FrmCssScopeHelper.php b/tests/phpunit/helpers/test_FrmCssScopeHelper.php index 6b351f019a..eca3cec14a 100644 --- a/tests/phpunit/helpers/test_FrmCssScopeHelper.php +++ b/tests/phpunit/helpers/test_FrmCssScopeHelper.php @@ -156,7 +156,7 @@ public function test_nest_empty_css() { $css = ''; $result = $this->helper->nest( $css, $this->scope_name ); - $this->assertEquals( '', $result ); + $this->assertSame( '', $result ); } /** @@ -310,6 +310,6 @@ public function test_unnest_empty_css() { $css = ''; $result = $this->helper->unnest( $css, $this->scope_name ); - $this->assertEquals( '', $result ); + $this->assertSame( '', $result ); } } diff --git a/tests/phpunit/misc/test_FrmAddon.php b/tests/phpunit/misc/test_FrmAddon.php index e0dd0cee74..5bd4850470 100644 --- a/tests/phpunit/misc/test_FrmAddon.php +++ b/tests/phpunit/misc/test_FrmAddon.php @@ -19,8 +19,8 @@ public function setUp(): void { * @covers FrmAddon::__construct */ public function test_construct() { - $this->assertEquals( 'signature', $this->addon->plugin_slug ); - $this->assertEquals( 'edd_signature_license_', $this->addon->option_name ); + $this->assertSame( 'signature', $this->addon->plugin_slug ); + $this->assertSame( 'edd_signature_license_', $this->addon->option_name ); // TODO: Test this line: $this->license = $this->get_license(); } diff --git a/tests/phpunit/misc/test_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index d460ce2388..074673081a 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->assertEquals( strpos( $path, '/' ), 0 ); + $this->assertSame( strpos( $path, '/' ), 0 ); } /** @@ -54,7 +54,7 @@ public function test_relative_plugin_url() { */ public function test_site_url() { $url = FrmAppHelper::site_url(); - $this->assertEquals( 'http://example.org', $url ); + $this->assertSame( 'http://example.org', $url ); } /** @@ -171,11 +171,11 @@ public function test_is_empty_value() { */ public function test_get_server_value() { $url = FrmAppHelper::get_server_value( 'HTTP_HOST' ); - $this->assertEquals( $url, 'example.org' ); + $this->assertSame( $url, 'example.org' ); $_SERVER['HTTP_HOST'] = 'example.org'; $url = FrmAppHelper::get_server_value( 'HTTP_HOST' ); - $this->assertEquals( $url, 'example.org' ); + $this->assertSame( $url, 'example.org' ); } /** @@ -259,7 +259,7 @@ public function test_get_simple_request() { 'param' => 'test5', ) ); - $this->assertEquals( '', $result ); + $this->assertSame( '', $result ); $set_value = 'test'; $expected = 'test'; @@ -308,7 +308,7 @@ public function test_kses() { $safe_value = 'Hello, click here'; $start_value .= $safe_value; $stripped_value = FrmAppHelper::kses( $start_value ); - $this->assertEquals( $stripped_value, 'Hello, click here' ); + $this->assertSame( $stripped_value, 'Hello, click here' ); $stripped_value = FrmAppHelper::kses( $start_value, array( 'a' ) ); $this->assertEquals( $stripped_value, $safe_value ); @@ -604,12 +604,12 @@ public function test_ctype_xdigit() { public function test_count_decimals() { $this->assertFalse( FrmAppHelper::count_decimals( 'str' ) ); $this->assertFalse( FrmAppHelper::count_decimals( '1.0.0' ) ); - $this->assertEquals( 0, FrmAppHelper::count_decimals( 13 ) ); - $this->assertEquals( 0, FrmAppHelper::count_decimals( '13' ) ); - $this->assertEquals( 1, FrmAppHelper::count_decimals( 13.1 ) ); - $this->assertEquals( 1, FrmAppHelper::count_decimals( '13.1' ) ); - $this->assertEquals( 3, FrmAppHelper::count_decimals( 13.123 ) ); - $this->assertEquals( 3, FrmAppHelper::count_decimals( '13.123' ) ); + $this->assertSame( 0, FrmAppHelper::count_decimals( 13 ) ); + $this->assertSame( 0, FrmAppHelper::count_decimals( '13' ) ); + $this->assertSame( 1, FrmAppHelper::count_decimals( 13.1 ) ); + $this->assertSame( 1, FrmAppHelper::count_decimals( '13.1' ) ); + $this->assertSame( 3, FrmAppHelper::count_decimals( 13.123 ) ); + $this->assertSame( 3, FrmAppHelper::count_decimals( '13.123' ) ); } /** @@ -622,7 +622,7 @@ public function test_get_ip_address() { $this->assertEquals( $_SERVER['REMOTE_ADDR'], FrmAppHelper::get_ip_address(), 'When custom header IPs are disabled, ignore headers like HTTP_X_FORWARDED_FOR.' ); add_filter( 'frm_use_custom_header_ip', '__return_true' ); - $this->assertEquals( '1.2.3.4', FrmAppHelper::get_ip_address(), 'When custom header IPs are enabled, we should check for headers like HTTP_X_FORWARDED_FOR' ); + $this->assertSame( '1.2.3.4', FrmAppHelper::get_ip_address(), 'When custom header IPs are enabled, we should check for headers like HTTP_X_FORWARDED_FOR' ); } /** @@ -630,19 +630,19 @@ public function test_get_ip_address() { */ public function test_human_time_diff() { $difference = FrmAppHelper::human_time_diff( 0, 0 ); - $this->assertEquals( '0 seconds', $difference ); + $this->assertSame( '0 seconds', $difference ); $difference = FrmAppHelper::human_time_diff( 0, 1 ); - $this->assertEquals( '1 second', $difference ); + $this->assertSame( '1 second', $difference ); $difference = FrmAppHelper::human_time_diff( 0, HOUR_IN_SECONDS ); - $this->assertEquals( '1 hour', $difference ); + $this->assertSame( '1 hour', $difference ); $difference = FrmAppHelper::human_time_diff( 0, DAY_IN_SECONDS ); - $this->assertEquals( '1 day', $difference ); + $this->assertSame( '1 day', $difference ); $difference = FrmAppHelper::human_time_diff( 0, DAY_IN_SECONDS * 2 ); - $this->assertEquals( '2 days', $difference ); + $this->assertSame( '2 days', $difference ); } /** @@ -653,13 +653,13 @@ public function test_unserialize_or_decode() { FrmAppHelper::unserialize_or_decode( $json_encoded_string ); $this->assertIsArray( $json_encoded_string ); $this->assertArrayHasKey( 'key', $json_encoded_string ); - $this->assertEquals( 'value', $json_encoded_string['key'] ); + $this->assertSame( 'value', $json_encoded_string['key'] ); $serialized_string = 'a:1:{s:3:"key";s:5:"value";}'; FrmAppHelper::unserialize_or_decode( $serialized_string ); $this->assertIsArray( $serialized_string ); $this->assertArrayHasKey( 'key', $serialized_string ); - $this->assertEquals( 'value', $serialized_string['key'] ); + $this->assertSame( 'value', $serialized_string['key'] ); } /** @@ -670,12 +670,12 @@ public function test_maybe_unserialize_array() { $unserialized_array = FrmAppHelper::maybe_unserialize_array( $serialized_string ); $this->assertIsArray( $unserialized_array ); $this->assertArrayHasKey( 'key', $unserialized_array ); - $this->assertEquals( 'value', $unserialized_array['key'] ); + $this->assertSame( 'value', $unserialized_array['key'] ); $serialized_string = 'O:8:"DateTime":0:{}'; $unserialized = FrmAppHelper::maybe_unserialize_array( $serialized_string ); $this->assertIsString( $unserialized ); - $this->assertEquals( 'O:8:"DateTime":0:{}', $unserialized, 'Serialized object data should remain serialized strings.' ); + $this->assertSame( 'O:8:"DateTime":0:{}', $unserialized, 'Serialized object data should remain serialized strings.' ); } /** @@ -687,18 +687,18 @@ public function test_clip() { echo '
    My html
    '; }; $html = FrmAppHelper::clip( $echo_function ); - $this->assertEquals( '
    My html
    ', $html ); + $this->assertSame( '
    My html
    ', $html ); // Test a callable string. $echo_function = self::class . '::echo_function'; $html = FrmAppHelper::clip( $echo_function ); - $this->assertEquals( '
    My echo function content
    ', $html ); + $this->assertSame( '
    My echo function content
    ', $html ); // Test something uncallable. // Make sure it isn't fatal just in case. $echo_function = self::class . '::something_uncallable'; $html = FrmAppHelper::clip( $echo_function ); - $this->assertEquals( '', $html ); + $this->assertSame( '', $html ); } /** diff --git a/tests/phpunit/misc/test_FrmSerializedStringParserHelper.php b/tests/phpunit/misc/test_FrmSerializedStringParserHelper.php index ee7baffeb8..cf22879ff2 100644 --- a/tests/phpunit/misc/test_FrmSerializedStringParserHelper.php +++ b/tests/phpunit/misc/test_FrmSerializedStringParserHelper.php @@ -16,6 +16,6 @@ public function test_parse() { $parsed = FrmSerializedStringParserHelper::get()->parse( $string ); $this->assertIsArray( $parsed ); $this->assertArrayHasKey( 'key', $parsed ); - $this->assertEquals( 'value', $parsed['key'] ); + $this->assertSame( 'value', $parsed['key'] ); } } diff --git a/tests/phpunit/onboarding-wizard/test_FrmOnboardingWizardController.php b/tests/phpunit/onboarding-wizard/test_FrmOnboardingWizardController.php index 963324c9f5..965bbd6ab7 100644 --- a/tests/phpunit/onboarding-wizard/test_FrmOnboardingWizardController.php +++ b/tests/phpunit/onboarding-wizard/test_FrmOnboardingWizardController.php @@ -26,14 +26,14 @@ public function test_do_admin_redirects() { // Case 1: Ensure no redirect action is taken when already on the Onboarding Wizard page. $_GET['page'] = $this->controller::PAGE_SLUG; $this->controller::do_admin_redirects(); - $this->assertNotEquals( 'no', get_transient( $this->controller::TRANSIENT_NAME ), 'No change to the transient is expected when already on the Onboarding Wizard page.' ); + $this->assertNotSame( 'no', get_transient( $this->controller::TRANSIENT_NAME ), 'No change to the transient is expected when already on the Onboarding Wizard page.' ); // Reset for the next case. unset( $_GET['page'] ); // Case 2: Ensure no redirect action is taken when onboarding has been previously skipped. update_option( $this->controller::ONBOARDING_SKIPPED_OPTION, true ); $this->controller::do_admin_redirects(); - $this->assertNotEquals( 'no', get_transient( $this->controller::TRANSIENT_NAME ), 'No change to the transient is expected when onboarding has been skipped.' ); + $this->assertNotSame( 'no', get_transient( $this->controller::TRANSIENT_NAME ), 'No change to the transient is expected when onboarding has been skipped.' ); // Reset for the next case. delete_option( $this->controller::ONBOARDING_SKIPPED_OPTION ); @@ -41,7 +41,7 @@ public function test_do_admin_redirects() { add_filter( 'wp_redirect', '__return_false' ); // Bypasses redirect and exit for uninterrupted PHPUnit execution. $_GET['page'] = 'formidable'; $this->controller::do_admin_redirects(); - $this->assertEquals( 'no', get_transient( $this->controller::TRANSIENT_NAME ), 'Transient should be set to "no" to indicate a redirect to the Onboarding Wizard is expected.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong + $this->assertSame( 'no', get_transient( $this->controller::TRANSIENT_NAME ), 'Transient should be set to "no" to indicate a redirect to the Onboarding Wizard is expected.' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong // Reset for the next case. unset( $_GET['page'] ); @@ -59,7 +59,7 @@ public function test_menu() { $this->controller::maybe_load_page(); - $this->assertEquals( 99, has_action( 'admin_menu', $this->controller . '::menu' ) ); + $this->assertSame( 99, has_action( 'admin_menu', $this->controller . '::menu' ) ); } /** diff --git a/tests/phpunit/stripe/test_FrmStripeLiteAuth.php b/tests/phpunit/stripe/test_FrmStripeLiteAuth.php index 062e6e2321..e9a5cd59a2 100644 --- a/tests/phpunit/stripe/test_FrmStripeLiteAuth.php +++ b/tests/phpunit/stripe/test_FrmStripeLiteAuth.php @@ -17,7 +17,7 @@ public function test_get_statement_descriptor() { add_filter( 'frm_stripe_statement_descriptor', $callback ); - $this->assertEquals( 'My Company', $this->get_statement_descriptor() ); + $this->assertSame( 'My Company', $this->get_statement_descriptor() ); remove_filter( 'frm_stripe_statement_descriptor', $callback ); } diff --git a/tests/phpunit/stripe/test_FrmStrpLiteActionsController.php b/tests/phpunit/stripe/test_FrmStrpLiteActionsController.php index 9e91220d37..ba10140759 100644 --- a/tests/phpunit/stripe/test_FrmStrpLiteActionsController.php +++ b/tests/phpunit/stripe/test_FrmStrpLiteActionsController.php @@ -11,10 +11,10 @@ class test_FrmStrpLiteActionsController extends FrmUnitTest { public function test_replace_email_shortcode() { $this->set_current_user_to_1(); $email_string = '[email]'; - $this->assertEquals( 'admin@example.org', $this->replace_email_shortcode( $email_string ) ); + $this->assertSame( 'admin@example.org', $this->replace_email_shortcode( $email_string ) ); $this->use_frm_role( 'loggedout' ); - $this->assertEquals( '', $this->replace_email_shortcode( $email_string ) ); + $this->assertSame( '', $this->replace_email_shortcode( $email_string ) ); } /** diff --git a/tests/phpunit/stripe/test_FrmTransLiteActionsController.php b/tests/phpunit/stripe/test_FrmTransLiteActionsController.php index 83610e3014..48c8a97244 100644 --- a/tests/phpunit/stripe/test_FrmTransLiteActionsController.php +++ b/tests/phpunit/stripe/test_FrmTransLiteActionsController.php @@ -55,18 +55,18 @@ public function test_maybe_use_decimal() { // Test with two decimal places. $amount = '111.50'; $this->maybe_use_decimal( $amount, $currency ); - $this->assertEquals( '111,50', $amount ); + $this->assertSame( '111,50', $amount ); // Test with a single decimal place. $amount = '111.5'; $this->maybe_use_decimal( $amount, $currency ); - $this->assertEquals( '111,5', $amount ); + $this->assertSame( '111,5', $amount ); // Test to make sure that three decimal places does not convert. // It should be interpreted as thousands. $amount = '111.500'; $this->maybe_use_decimal( $amount, $currency ); - $this->assertEquals( '111.500', $amount ); + $this->assertSame( '111.500', $amount ); } /** diff --git a/tests/phpunit/styles/test_FrmStyle.php b/tests/phpunit/styles/test_FrmStyle.php index 3462a488b0..bf1f9d07c6 100644 --- a/tests/phpunit/styles/test_FrmStyle.php +++ b/tests/phpunit/styles/test_FrmStyle.php @@ -63,20 +63,20 @@ public function test_sanitize_post_content() { $sanitized_post_content = $frm_style->sanitize_post_content( $post_content ); $this->assertIsArray( $sanitized_post_content ); - $this->assertEquals( '000', $sanitized_post_content['bg_color'] ); - $this->assertEquals( '14px', $sanitized_post_content['font_size'] ); - $this->assertEquals( '60px', $sanitized_post_content['title_margin_bottom'] ); - $this->assertEquals( '12px', $sanitized_post_content['field_height'] ); - $this->assertEquals( '10px', $sanitized_post_content['field_width'] ); - $this->assertEquals( 'calc(100% / 3)', $sanitized_post_content['width'] ); - $this->assertEquals( 'rgba(255,255,255,1)', $sanitized_post_content['section_color'] ); - $this->assertEquals( 'ffffff', $sanitized_post_content['submit_border_color'] ); - $this->assertEquals( 'rgb(255,255,255)', $sanitized_post_content['submit_active_color'] ); - $this->assertEquals( '000', $sanitized_post_content['progress_bg_color'] ); - $this->assertEquals( 'fff', $sanitized_post_content['success_bg_color'] ); - $this->assertEquals( '12px', $sanitized_post_content['section_border_width'] ); - $this->assertEquals( '16px', $sanitized_post_content['section_font_size'] ); - $this->assertEquals( '.my-class { color: red; }', $sanitized_post_content['custom_css'] ); + $this->assertSame( '000', $sanitized_post_content['bg_color'] ); + $this->assertSame( '14px', $sanitized_post_content['font_size'] ); + $this->assertSame( '60px', $sanitized_post_content['title_margin_bottom'] ); + $this->assertSame( '12px', $sanitized_post_content['field_height'] ); + $this->assertSame( '10px', $sanitized_post_content['field_width'] ); + $this->assertSame( 'calc(100% / 3)', $sanitized_post_content['width'] ); + $this->assertSame( 'rgba(255,255,255,1)', $sanitized_post_content['section_color'] ); + $this->assertSame( 'ffffff', $sanitized_post_content['submit_border_color'] ); + $this->assertSame( 'rgb(255,255,255)', $sanitized_post_content['submit_active_color'] ); + $this->assertSame( '000', $sanitized_post_content['progress_bg_color'] ); + $this->assertSame( 'fff', $sanitized_post_content['success_bg_color'] ); + $this->assertSame( '12px', $sanitized_post_content['section_border_width'] ); + $this->assertSame( '16px', $sanitized_post_content['section_font_size'] ); + $this->assertSame( '.my-class { color: red; }', $sanitized_post_content['custom_css'] ); $this->assertArrayNotHasKey( 'unsupported_key', $sanitized_post_content ); } @@ -85,26 +85,26 @@ public function test_sanitize_post_content() { */ public function test_strip_invalid_characters() { // Make sure that braces don't get added to sizes but removed instead. - $this->assertEquals( '12px', $this->strip_invalid_characters( '12px(' ) ); - $this->assertEquals( '2rem', $this->strip_invalid_characters( ')2rem' ) ); - $this->assertEquals( '10pt', $this->strip_invalid_characters( '(10pt' ) ); - $this->assertEquals( '100%', $this->strip_invalid_characters( '100%)' ) ); - $this->assertEquals( '14px', $this->strip_invalid_characters( '(14px)' ) ); - $this->assertEquals( '20PX', $this->strip_invalid_characters( ')20PX' ), 'strip_invalid_characters should be case insensitive' ); + $this->assertSame( '12px', $this->strip_invalid_characters( '12px(' ) ); + $this->assertSame( '2rem', $this->strip_invalid_characters( ')2rem' ) ); + $this->assertSame( '10pt', $this->strip_invalid_characters( '(10pt' ) ); + $this->assertSame( '100%', $this->strip_invalid_characters( '100%)' ) ); + $this->assertSame( '14px', $this->strip_invalid_characters( '(14px)' ) ); + $this->assertSame( '20PX', $this->strip_invalid_characters( ')20PX' ), 'strip_invalid_characters should be case insensitive' ); // Test CSS vars. - $this->assertEquals( 'var(--grey)', $this->strip_invalid_characters( '(var(--grey)' ) ); - $this->assertEquals( 'var(--white)', $this->strip_invalid_characters( '(var(--white)))' ) ); + $this->assertSame( 'var(--grey)', $this->strip_invalid_characters( '(var(--grey)' ) ); + $this->assertSame( 'var(--white)', $this->strip_invalid_characters( '(var(--white)))' ) ); // Test some calc() rules with extra braces. - $this->assertEquals( 'calc(50%/3)', $this->strip_invalid_characters( '(calc(50%/3)' ) ); - $this->assertEquals( 'calc(10%*5)', $this->strip_invalid_characters( ')calc(10%*5)' ) ); + $this->assertSame( 'calc(50%/3)', $this->strip_invalid_characters( '(calc(50%/3)' ) ); + $this->assertSame( 'calc(10%*5)', $this->strip_invalid_characters( ')calc(10%*5)' ) ); // Test some things that should not change. - $this->assertEquals( 'fff', $this->strip_invalid_characters( 'fff' ) ); - $this->assertEquals( '12px', $this->strip_invalid_characters( '12px' ) ); - $this->assertEquals( 'rgb(0,0,0)', $this->strip_invalid_characters( 'rgb(0,0,0)' ) ); - $this->assertEquals( 'calc(100%/6)', $this->strip_invalid_characters( 'calc(100%/6)' ) ); + $this->assertSame( 'fff', $this->strip_invalid_characters( 'fff' ) ); + $this->assertSame( '12px', $this->strip_invalid_characters( '12px' ) ); + $this->assertSame( 'rgb(0,0,0)', $this->strip_invalid_characters( 'rgb(0,0,0)' ) ); + $this->assertSame( 'calc(100%/6)', $this->strip_invalid_characters( 'calc(100%/6)' ) ); } /** @@ -122,29 +122,29 @@ public function test_force_balanced_quotation() { $frm_style = new FrmStyle(); // Test a case where nothing changes. - $this->assertEquals( '"Arial"', $frm_style->force_balanced_quotation( '"Arial"' ) ); + $this->assertSame( '"Arial"', $frm_style->force_balanced_quotation( '"Arial"' ) ); // Balance a missing " at the end. - $this->assertEquals( '"Verdana"', $frm_style->force_balanced_quotation( '"Verdana' ) ); + $this->assertSame( '"Verdana"', $frm_style->force_balanced_quotation( '"Verdana' ) ); // Balance a missing ' at the end. - $this->assertEquals( "'Times New Roman'", $frm_style->force_balanced_quotation( "'Times New Roman" ) ); + $this->assertSame( "'Times New Roman'", $frm_style->force_balanced_quotation( "'Times New Roman" ) ); // Balance a missing " at the front. - $this->assertEquals( '"Helvetica"', $frm_style->force_balanced_quotation( 'Helvetica"' ) ); + $this->assertSame( '"Helvetica"', $frm_style->force_balanced_quotation( 'Helvetica"' ) ); // Balance a missing ' at the front. - $this->assertEquals( "'Comic Sans'", $frm_style->force_balanced_quotation( "Comic Sans'" ) ); + $this->assertSame( "'Comic Sans'", $frm_style->force_balanced_quotation( "Comic Sans'" ) ); } /** * @gcovers FrmStyle::trim_braces */ public function test_trim_braces() { - $this->assertEquals( 'calc(100%)', $this->trim_braces( '(calc(100%)))' ) ); - $this->assertEquals( 'skewX(5px)', $this->trim_braces( '((skewX(5px)' ) ); - $this->assertEquals( 'var(--grey)', $this->trim_braces( '(var(--grey))' ) ); - $this->assertEquals( 'scale(2)', $this->trim_braces( '(scale(2)))' ) ); + $this->assertSame( 'calc(100%)', $this->trim_braces( '(calc(100%)))' ) ); + $this->assertSame( 'skewX(5px)', $this->trim_braces( '((skewX(5px)' ) ); + $this->assertSame( 'var(--grey)', $this->trim_braces( '(var(--grey))' ) ); + $this->assertSame( 'scale(2)', $this->trim_braces( '(scale(2)))' ) ); } /** diff --git a/tests/phpunit/styles/test_FrmStylesHelper.php b/tests/phpunit/styles/test_FrmStylesHelper.php index ea31fb3fb2..c1441833c0 100644 --- a/tests/phpunit/styles/test_FrmStylesHelper.php +++ b/tests/phpunit/styles/test_FrmStylesHelper.php @@ -39,7 +39,7 @@ public function test_get_settings_for_output() { $settings = FrmStylesHelper::get_settings_for_output( $style ); $expected = 'frm_style_test.with_frm_style'; $this->assertEquals( $expected, $settings['style_class'] ); - $this->assertEquals( '#000000', $settings['fieldset_color'] ); + $this->assertSame( '#000000', $settings['fieldset_color'] ); } /** @@ -53,7 +53,7 @@ public function test_single_instance_in_css() { $style = $frm_style->get_one(); $settings = FrmStylesHelper::get_settings_for_output( $style ); $css_contains = substr_count( $compiled_css, '}.frm_forms.' . $settings['style_class'] . '{' ); - $this->assertEquals( 1, $css_contains, 'Multiple or no occurrences of style found' ); + $this->assertSame( 1, $css_contains, 'Multiple or no occurrences of style found' ); } /** @@ -108,7 +108,7 @@ public function test_get_form_count_for_style() { $new_style_id = $this->factory->post->create( array( 'post_type' => FrmStylesController::$post_type ) ); - $this->assertEquals( 0, FrmStylesHelper::get_form_count_for_style( $new_style_id, false ) ); + $this->assertSame( 0, FrmStylesHelper::get_form_count_for_style( $new_style_id, false ) ); $this->factory->form->create( array( @@ -118,7 +118,7 @@ public function test_get_form_count_for_style() { ), ) ); - $this->assertEquals( 1, FrmStylesHelper::get_form_count_for_style( $new_style_id, false ) ); + $this->assertSame( 1, FrmStylesHelper::get_form_count_for_style( $new_style_id, false ) ); $data_for_all_published_forms = FrmDb::get_results( 'frm_forms', array( 'status' => 'published' ), 'id, options' ); $default_count = 0; @@ -151,7 +151,7 @@ public function test_get_form_count_for_style() { $cache_key = FrmDb::generate_cache_key( $where, $args, 'ID', 'var' ); wp_cache_delete( $cache_key, 'post' ); - $this->assertEquals( 0, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, true ) ); + $this->assertSame( 0, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, true ) ); // Add a form with the conversational default. $this->factory->form->create( @@ -163,8 +163,8 @@ public function test_get_form_count_for_style() { ) ); - $this->assertEquals( 1, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, true ) ); - $this->assertEquals( 0, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, false ) ); + $this->assertSame( 1, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, true ) ); + $this->assertSame( 0, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, false ) ); // Create a second conversational form. $this->factory->form->create( @@ -176,8 +176,8 @@ public function test_get_form_count_for_style() { ) ); - $this->assertEquals( 1, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, false ) ); - $this->assertEquals( 2, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, true ) ); + $this->assertSame( 1, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, false ) ); + $this->assertSame( 2, FrmStylesHelper::get_form_count_for_style( $conversational_style_id, true ) ); } /** diff --git a/tests/phpunit/xml/test_FrmXMLHelper.php b/tests/phpunit/xml/test_FrmXMLHelper.php index 3843da049e..7ac7995328 100644 --- a/tests/phpunit/xml/test_FrmXMLHelper.php +++ b/tests/phpunit/xml/test_FrmXMLHelper.php @@ -147,12 +147,12 @@ private function maybe_fix_xml( &$xml_string ) { * @covers FrmAppHelper::maybe_utf8_encode */ public function test_cdata() { - $this->assertEquals( '', FrmXMLHelper::cdata( 'Name' ) ); - $this->assertEquals( '', FrmXMLHelper::cdata( '29yf4d' ) ); - $this->assertEquals( '', FrmXMLHelper::cdata( 'United States' ) ); - $this->assertEquals( '', FrmXMLHelper::cdata( serialize( array( 'Red', 'Blue' ) ) ) ); - $this->assertEquals( '', FrmXMLHelper::cdata( serialize( array( 60418, 60419, 60420 ) ) ) ); - $this->assertEquals( + $this->assertSame( '', FrmXMLHelper::cdata( 'Name' ) ); + $this->assertSame( '', FrmXMLHelper::cdata( '29yf4d' ) ); + $this->assertSame( '', FrmXMLHelper::cdata( 'United States' ) ); + $this->assertSame( '', FrmXMLHelper::cdata( serialize( array( 'Red', 'Blue' ) ) ) ); + $this->assertSame( '', FrmXMLHelper::cdata( serialize( array( 60418, 60419, 60420 ) ) ) ); + $this->assertSame( '', // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong FrmXMLHelper::cdata( serialize( @@ -163,11 +163,11 @@ public function test_cdata() { ) ) ); - $this->assertEquals( '5', FrmXMLHelper::cdata( '5' ), 'Numbers do not need to be wrapped' ); - $this->assertEquals( '', FrmXMLHelper::cdata( '2023-05-21' ) ); + $this->assertSame( '5', FrmXMLHelper::cdata( '5' ), 'Numbers do not need to be wrapped' ); + $this->assertSame( '', FrmXMLHelper::cdata( '2023-05-21' ) ); // Test that a ISO-8859-1 characters (\xC1 and \xE9) convert to UTF-8. - $this->assertEquals( '', FrmXMLHelper::cdata( "Hello\xC1World" ) ); // \xC1 is the Á character. - $this->assertEquals( '', FrmXMLHelper::cdata( "\xE9" ) ); // \xE9 is the é character. + $this->assertSame( '', FrmXMLHelper::cdata( "Hello\xC1World" ) ); // \xC1 is the Á character. + $this->assertSame( '', FrmXMLHelper::cdata( "\xE9" ) ); // \xE9 is the é character. } }