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/category/wpListCategories.php

    r51462 r51565  
    3131
    3232        $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found );
    33         $this->assertRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found );
     33        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found );
    3434    }
    3535
     
    5050        );
    5151
    52         $this->assertRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found );
     52        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found );
    5353        $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found );
    5454    }
     
    6868        );
    6969
    70         $this->assertRegExp( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found );
     70        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found );
    7171        $this->assertNotRegExp( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found );
    72         $this->assertRegExp( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found );
     72        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found );
    7373    }
    7474
     
    651651        );
    652652
    653         $this->assertRegExp( '/class="[^"]*cat-item-' . $parent . '[^"]*current-cat-ancestor[^"]*"/', $actual );
    654         $this->assertRegExp( '/class="[^"]*cat-item-' . $child . '[^"]*current-cat-ancestor[^"]*"/', $actual );
     653        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $parent . '[^"]*current-cat-ancestor[^"]*"/', $actual );
     654        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $child . '[^"]*current-cat-ancestor[^"]*"/', $actual );
    655655        $this->assertNotRegExp( '/class="[^"]*cat-item-' . $grandchild . '[^"]*current-cat-ancestor[^"]*"/', $actual );
    656656        $this->assertNotRegExp( '/class="[^"]*cat-item-' . $child2 . '[^"]*current-cat-ancestor[^"]*"/', $actual );
Note: See TracChangeset for help on using the changeset viewer.