Make WordPress Core


Ignore:
Timestamp:
08/06/2021 09:52:06 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Replace assertRegExp() with assertMatchesRegularExpression().

The assertRegExp() and assertNotRegExp() methods were hard deprecated in PHPUnit 9.1 and the functionality will be removed in PHPUnit 10.0.

The assertMatchesRegularExpression() and assertDoesNotMatchRegularExpression() methods were introduced as a replacement in PHPUnit 9.1.

These new PHPUnit methods are polyfilled by the PHPUnit Polyfills and switching to them will future-proof the tests some more.

References:

Follow-up to [51559-51564].

Props jrf.
See #46149.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment/commentForm.php

    r51462 r51565  
    1919        $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />';
    2020        $hidden = get_comment_id_fields( $p );
    21         $this->assertRegExp( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
     21        $this->assertMatchesRegularExpression( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
    2222    }
    2323
     
    5454        $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />';
    5555        $hidden = get_comment_id_fields( $p );
    56         $this->assertRegExp( '|<p class="my\-custom\-submit\-field">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
     56        $this->assertMatchesRegularExpression( '|<p class="my\-custom\-submit\-field">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
    5757    }
    5858
     
    7676        $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />';
    7777        $hidden = get_comment_id_fields( $p );
    78         $this->assertRegExp( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
     78        $this->assertMatchesRegularExpression( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form );
    7979    }
    8080
     
    103103        remove_filter( 'option_show_comments_cookies_opt_in', '__return_true' );
    104104
    105         $this->assertRegExp( '|<p class="comment\-form\-cookies\-consent">.*?</p>|', $form );
     105        $this->assertMatchesRegularExpression( '|<p class="comment\-form\-cookies\-consent">.*?</p>|', $form );
    106106    }
    107107
Note: See TracChangeset for help on using the changeset viewer.