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/customize/nav-menus.php

    r51462 r51565  
    771771            foreach ( $post_types as $type ) {
    772772                $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
    773                 $this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template );
     773                $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template );
    774774                $this->assertStringContainsString( 'data-type="post_type"', $template );
    775775                $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template );
     
    782782            foreach ( $taxonomies as $tax ) {
    783783                $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
    784                 $this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template );
     784                $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template );
    785785                $this->assertStringContainsString( 'data-type="taxonomy"', $template );
    786786                $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
     
    790790
    791791        $this->assertStringContainsString( 'available-menu-items-custom_type', $template );
    792         $this->assertRegExp( '#<h4 class="accordion-section-title".*>\s*Custom#', $template );
     792        $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*Custom#', $template );
    793793        $this->assertStringContainsString( 'data-type="custom_type"', $template );
    794794        $this->assertStringContainsString( 'data-object="custom_object"', $template );
     
    10141014        foreach ( $drafted_post_ids as $post_id ) {
    10151015            $this->assertSame( 'publish', get_post_status( $post_id ) );
    1016             $this->assertRegExp( '/^auto-draft-\d+$/', get_post( $post_id )->post_name );
     1016            $this->assertMatchesRegularExpression( '/^auto-draft-\d+$/', get_post( $post_id )->post_name );
    10171017            $this->assertEmpty( get_post_meta( $post_id, '_customize_draft_post_name', true ) );
    10181018        }
Note: See TracChangeset for help on using the changeset viewer.