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..d8eb684b7c 100644 --- a/rector.php +++ b/rector.php @@ -67,9 +67,24 @@ 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; +use Rector\PHPUnit\CodeQuality\Rector\MethodCall\StringCastAssertStringContainsStringRector; return RectorConfig::configure() + ->withBootstrapFiles( + array( + __DIR__ . '/stubs.php', + ) + ) + ->withAutoloadPaths( + array( + __DIR__ . '/tests/phpunit/base', + ) + ) ->withPaths( array( __DIR__ . '/classes', @@ -215,5 +230,12 @@ AddParamArrayDocblockFromDimFetchAccessRector::class, DocblockReturnArrayFromDirectArrayInstanceRector::class, AddReturnDocblockForDimFetchArrayFromAssignsRector::class, + + // PHP Unit + DeclareStrictTypesTestsRector::class, + FinalizeTestCaseClassRector::class, + PrivatizeFinalClassPropertyRector::class, + StringClassNameToClassConstantRector::class, + StringCastAssertStringContainsStringRector::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/database/test_FrmMigrate.php b/tests/phpunit/database/test_FrmMigrate.php index 8cb892921b..8721970356 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,7 +361,7 @@ 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.' ); diff --git a/tests/phpunit/emails/test_FrmEmailSummaryHelper.php b/tests/phpunit/emails/test_FrmEmailSummaryHelper.php index 3a5721fc32..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->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..a9afc627a7 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->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 ); $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..5ea1ce807f 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->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'] ); @@ -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..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->assertTrue( $field_id > 0 ); + $this->assertGreaterThan( 0, $field_id ); } } diff --git a/tests/phpunit/fields/test_FrmFieldGridHelper.php.php b/tests/phpunit/fields/test_FrmFieldGridHelper.php.php index 7cf9c66f65..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->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_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..ca1956938a 100644 --- a/tests/phpunit/form-templates/test_FrmFormTemplatesController.php +++ b/tests/phpunit/form-templates/test_FrmFormTemplatesController.php @@ -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..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->assertTrue( isset( $wp_widget_factory->widgets['FrmShowForm'] ) ); + $this->assertArrayHasKey( 'FrmShowForm', $wp_widget_factory->widgets ); } public function test_head() { 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..dffd0b6070 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..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->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_FrmAppHelper.php b/tests/phpunit/misc/test_FrmAppHelper.php index 9f6771adfd..b3eeb159d6 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 ); @@ -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_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..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->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' ) ); } 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..64d5e4717b 100644 --- a/tests/phpunit/styles/test_FrmStyleApi.php +++ b/tests/phpunit/styles/test_FrmStyleApi.php @@ -32,6 +32,6 @@ public function test_get_api_info() { $this->assertStringContainsString( '.png', $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..b0cb69e350 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; } diff --git a/tests/phpunit/styles/test_FrmStylesHelper.php b/tests/phpunit/styles/test_FrmStylesHelper.php index 13d6af07ff..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->assertTrue( isset( $base['baseurl'] ) ); + $this->assertArrayHasKey( 'baseurl', $base ); $this->assertStringContainsString( 'http://', $base['baseurl'] ); $_SERVER['HTTPS'] = 'on'; 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(