Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/models/FrmAntiSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
);

Expand Down
24 changes: 23 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -215,5 +230,12 @@
AddParamArrayDocblockFromDimFetchAccessRector::class,
DocblockReturnArrayFromDirectArrayInstanceRector::class,
AddReturnDocblockForDimFetchArrayFromAssignsRector::class,

// PHP Unit
DeclareStrictTypesTestsRector::class,
FinalizeTestCaseClassRector::class,
PrivatizeFinalClassPropertyRector::class,
StringClassNameToClassConstantRector::class,
StringCastAssertStringContainsStringRector::class,
)
);
6 changes: 6 additions & 0 deletions stubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/database/test_FrmMigrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down Expand Up @@ -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.' );

Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/emails/test_FrmEmailSummaryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/entries/test_FrmEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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 );

Expand Down
12 changes: 6 additions & 6 deletions tests/phpunit/entries/test_FrmEntryValidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] );
Expand Down Expand Up @@ -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] );
Expand Down Expand Up @@ -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'] );
}
}
2 changes: 1 addition & 1 deletion tests/phpunit/fields/test_FrmField.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function test_create() {
)
);
$this->assertIsNumeric( $field_id );
$this->assertTrue( $field_id > 0 );
$this->assertGreaterThan( 0, $field_id );
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/fields/test_FrmFieldGridHelper.php.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
Expand Down
18 changes: 9 additions & 9 deletions tests/phpunit/fields/test_FrmFieldValidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

/**
Expand All @@ -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 ) );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo in error message: "Email email" → "Empty email".

-		$this->assertArrayHasKey( 'field' . $field->id, $errors, 'Email email passed required validation ' . print_r( $errors, 1 ) );
+		$this->assertArrayHasKey( 'field' . $field->id, $errors, 'Empty email passed required validation ' . print_r( $errors, 1 ) );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$this->assertArrayHasKey( 'field' . $field->id, $errors, 'Email email passed required validation ' . print_r( $errors, 1 ) );
$this->assertArrayHasKey( 'field' . $field->id, $errors, 'Empty email passed required validation ' . print_r( $errors, 1 ) );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/phpunit/fields/test_FrmFieldValidate.php` at line 198, Fix the typo in
the assertion message for the validation test: update the message passed to
$this->assertArrayHasKey that currently reads 'Email email passed required
validation ...' to instead read 'Empty email passed required validation ...',
keeping the rest of the message (including concatenation with print_r($errors,
1)) and references to 'field' . $field->id and $errors unchanged.


$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 ) );
}

/**
Expand All @@ -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(
Expand All @@ -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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.' );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/forms/test_FrmForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/forms/test_FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/forms/test_FrmOnSubmitAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] );
}
}
5 changes: 2 additions & 3 deletions tests/phpunit/misc/test_FrmAddon.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Comment on lines +13 to 14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the required/installed PHPUnit version
rg -i 'phpunit' composer.json -A 2 -B 2

Repository: Strategy11/formidable-forms

Length of output: 234


🌐 Web query:

PHPUnit MockBuilder setMethods deprecated removed version timeline

💡 Result:

PHPUnit MockBuilder::setMethods() deprecation/removal timeline

  • Introduced replacements in PHPUnit 8 (2019): onlyMethods() (mock existing methods) and addMethods() (mock non-existing methods) were added as the intended split of setMethods() responsibilities (see PR #3687 referenced by multiple downstream projects). [2]
  • Deprecated in PHPUnit 8.3.0: MockBuilder::setMethods() was deprecated (but it notably did not always emit a deprecation warning at runtime, which caused confusion). [1]
  • Removed in PHPUnit 10.0: MockBuilder::setMethods() no longer exists; you must migrate to onlyMethods() and/or addMethods() (or drop the call if unnecessary). [1][2]

Migration mapping

  • setMethods(['a','b'])onlyMethods(['a','b']) (when methods exist) [3]
  • If you previously used setMethods() to “mock” methods that don’t exist on the class, use addMethods([...]) instead. [3]

Sources: Moodle upgrade notes [1], Drupal issue referencing PR #3687 and removal in PHPUnit 10 [2], PHPUnit manual (onlyMethods() / addMethods()) [3].


🏁 Script executed:

#!/bin/bash
# Get the full composer.json to find PHPUnit version
cat composer.json | jq '.require, .require-dev' 2>/dev/null || head -100 composer.json

Repository: Strategy11/formidable-forms

Length of output: 1408


🏁 Script executed:

#!/bin/bash
# Also check composer.lock for installed PHPUnit version
rg '"name": "phpunit' composer.lock -A 2 | head -20

Repository: Strategy11/formidable-forms

Length of output: 124


🏁 Script executed:

#!/bin/bash
# Find phpunit configuration
fd -name 'phpunit.xml*'

Repository: Strategy11/formidable-forms

Length of output: 301


🏁 Script executed:

#!/bin/bash
# Check the test file to understand what setMethods() is doing
cat -n tests/phpunit/misc/test_FrmAddon.php | head -40

Repository: Strategy11/formidable-forms

Length of output: 1335


🏁 Script executed:

#!/bin/bash
# Find phpunit configuration files
fd phpunit

Repository: Strategy11/formidable-forms

Length of output: 137


🏁 Script executed:

#!/bin/bash
# Check if there are any CI/workflow files that specify PHPUnit version
fd -e yml -e yaml | xargs grep -l phpunit 2>/dev/null | head -5

Repository: Strategy11/formidable-forms

Length of output: 53


🏁 Script executed:

#!/bin/bash
# Check the phpunit.xml file
cat phpunit.xml

Repository: Strategy11/formidable-forms

Length of output: 949


🏁 Script executed:

#!/bin/bash
# Check bootstrap file for PHPUnit version hints
cat tests/phpunit/bootstrap.php | head -50

Repository: Strategy11/formidable-forms

Length of output: 1028


🏁 Script executed:

#!/bin/bash
# Check GitHub workflows for PHPUnit version
fd -e yml -e yaml .github 2>/dev/null | xargs cat 2>/dev/null | grep -i phpunit -C 3 || echo "No workflows found"

Repository: Strategy11/formidable-forms

Length of output: 89


🏁 Script executed:

#!/bin/bash
# Check if there's a .github/workflows directory or CI config
find . -type d -name '.github' -o -name '.gitlab-ci*' -o -name '.travis*' 2>/dev/null | head -5

Repository: Strategy11/formidable-forms

Length of output: 80


🏁 Script executed:

#!/bin/bash
# Check README or documentation for PHPUnit version requirements
find . -maxdepth 2 -type f \( -name 'README*' -o -name 'CONTRIBUTE*' -o -name 'DEV*' \) -exec head -50 {} \; 2>/dev/null | grep -i phpunit -C 2 || echo "No PHPUnit version info in docs"

Repository: Strategy11/formidable-forms

Length of output: 102


🏁 Script executed:

#!/bin/bash
# List contents of .github directory
ls -la .github/

Repository: Strategy11/formidable-forms

Length of output: 311


🏁 Script executed:

#!/bin/bash
# Check all YAML files in .github for PHPUnit mentions
find .github -type f -name '*.yml' -o -name '*.yaml' | xargs cat 2>/dev/null

Repository: Strategy11/formidable-forms

Length of output: 13279


Remove the no-op setMethods() call.

MockBuilder::setMethods() was deprecated in PHPUnit 8.3 and removed in PHPUnit 10.0. The call on lines 13–14 with no arguments is a no-op (equivalent to setMethods(null)) and should be removed entirely. This ensures compatibility with both current and future PHPUnit versions.

Current code:
$this->addon = $this->getMockBuilder( 'FrmTestAddon' )->setMethods()
                            ->getMock();

Remove ->setMethods() from the chain.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/phpunit/misc/test_FrmAddon.php` around lines 13 - 14, The test
constructs a mock for FrmTestAddon using getMockBuilder but includes a no-op
call to setMethods() which is deprecated/removed; remove the ->setMethods() call
from the chain so the mock is built as
$this->getMockBuilder('FrmTestAddon')->getMock() (i.e., locate the
getMockBuilder('FrmTestAddon') call in tests/phpunit/misc/test_FrmAddon.php and
delete the setMethods() invocation).

}

Expand All @@ -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 );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/misc/test_FrmAntiSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

/**
Expand All @@ -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 ) );
}

/**
Expand All @@ -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 ) );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/misc/test_FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/misc/test_FrmHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}
}
4 changes: 2 additions & 2 deletions tests/phpunit/misc/test_FrmMisc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
Expand Down
Loading
Loading