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/post/template.php

    r51462 r51565  
    341341        );
    342342
    343         $this->assertRegExp( '/<select[^>]+class=\'bar\'/', $found );
     343        $this->assertMatchesRegularExpression( '/<select[^>]+class=\'bar\'/', $found );
    344344    }
    345345
     
    420420
    421421        // After falling back, the 'before' argument should be set and output as '<ul>'.
    422         $this->assertRegExp( '/<div class="menu"><ul>/', $menu );
     422        $this->assertMatchesRegularExpression( '/<div class="menu"><ul>/', $menu );
    423423
    424424        // After falling back, the 'after' argument should be set and output as '</ul>'.
    425         $this->assertRegExp( '/<\/ul><\/div>/', $menu );
     425        $this->assertMatchesRegularExpression( '/<\/ul><\/div>/', $menu );
    426426
    427427        // After falling back, the markup should include whitespace around <li>'s.
    428         $this->assertRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
     428        $this->assertMatchesRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
    429429        $this->assertNotRegExp( '/><li.*>|<\/li></U', $menu );
    430430
     
    438438
    439439        // After falling back, the empty 'container' argument should still return a container element.
    440         $this->assertRegExp( '/<div class="menu">/', $menu );
     440        $this->assertMatchesRegularExpression( '/<div class="menu">/', $menu );
    441441
    442442        // No menus + wp_nav_menu() falls back to wp_page_menu(), this time without white-space.
     
    450450        // After falling back, the markup should not include whitespace around <li>'s.
    451451        $this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
    452         $this->assertRegExp( '/><li.*>|<\/li></U', $menu );
     452        $this->assertMatchesRegularExpression( '/><li.*>|<\/li></U', $menu );
    453453
    454454    }
Note: See TracChangeset for help on using the changeset viewer.