Make WordPress Core

Changeset 51566


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

Tests: Replace assertNotRegExp() with assertDoesNotMatchRegularExpression().

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-51565].

Props jrf.
See #46149.

Location:
trunk/tests/phpunit/tests
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/category/wpDropdownCategories.php

    r51565 r51566  
    228228
    229229        // Test to see if it contains the "required" attribute.
    230         $this->assertNotRegExp( '/<select[^>]+required/', $dropdown_categories );
     230        $this->assertDoesNotMatchRegularExpression( '/<select[^>]+required/', $dropdown_categories );
    231231    }
    232232
     
    252252
    253253        // Test to see if it contains the "required" attribute.
    254         $this->assertNotRegExp( '/<select[^>]+required/', $dropdown_categories );
     254        $this->assertDoesNotMatchRegularExpression( '/<select[^>]+required/', $dropdown_categories );
    255255    }
    256256}
  • trunk/tests/phpunit/tests/category/wpListCategories.php

    r51565 r51566  
    3030        );
    3131
    32         $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found );
     32        $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found );
    3333        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found );
    3434    }
     
    5151
    5252        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found );
    53         $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found );
     53        $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found );
    5454    }
    5555
     
    6969
    7070        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found );
    71         $this->assertNotRegExp( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found );
     71        $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found );
    7272        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found );
    7373    }
     
    653653        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $parent . '[^"]*current-cat-ancestor[^"]*"/', $actual );
    654654        $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $child . '[^"]*current-cat-ancestor[^"]*"/', $actual );
    655         $this->assertNotRegExp( '/class="[^"]*cat-item-' . $grandchild . '[^"]*current-cat-ancestor[^"]*"/', $actual );
    656         $this->assertNotRegExp( '/class="[^"]*cat-item-' . $child2 . '[^"]*current-cat-ancestor[^"]*"/', $actual );
     655        $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $grandchild . '[^"]*current-cat-ancestor[^"]*"/', $actual );
     656        $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $child2 . '[^"]*current-cat-ancestor[^"]*"/', $actual );
    657657    }
    658658}
  • trunk/tests/phpunit/tests/menu/walker-nav-menu-edit.php

    r47198 r51566  
    5656        $this->walker->start_el( $expected, (object) $item );
    5757
    58         $this->assertNotRegExp( '#<p class="link-to-original">\s*Original: <a href=""></a>#', $expected );
     58        $this->assertDoesNotMatchRegularExpression( '#<p class="link-to-original">\s*Original: <a href=""></a>#', $expected );
    5959    }
    6060}
  • trunk/tests/phpunit/tests/post/getPostsByAuthorSql.php

    r51565 r51566  
    4040    public function test_full_false() {
    4141        $maybe_string = get_posts_by_author_sql( 'post', false );
    42         $this->assertNotRegExp( '/^WHERE /', $maybe_string );
     42        $this->assertDoesNotMatchRegularExpression( '/^WHERE /', $maybe_string );
    4343    }
    4444
  • trunk/tests/phpunit/tests/post/nav-menu.php

    r51565 r51566  
    462462        // The markup should include whitespace between <li>'s.
    463463        $this->assertMatchesRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
    464         $this->assertNotRegExp( '/<\/li><li.*>/U', $menu );
     464        $this->assertDoesNotMatchRegularExpression( '/<\/li><li.*>/U', $menu );
    465465
    466466        // Whitespace suppressed.
     
    474474
    475475        // The markup should not include whitespace around <li>'s.
    476         $this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
     476        $this->assertDoesNotMatchRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
    477477        $this->assertMatchesRegularExpression( '/><li.*>|<\/li></U', $menu );
    478478    }
  • trunk/tests/phpunit/tests/post/template.php

    r51565 r51566  
    320320        );
    321321
    322         $this->assertNotRegExp( '/<select[^>]+class=\'/', $found );
     322        $this->assertDoesNotMatchRegularExpression( '/<select[^>]+class=\'/', $found );
    323323    }
    324324
     
    427427        // After falling back, the markup should include whitespace around <li>'s.
    428428        $this->assertMatchesRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
    429         $this->assertNotRegExp( '/><li.*>|<\/li></U', $menu );
     429        $this->assertDoesNotMatchRegularExpression( '/><li.*>|<\/li></U', $menu );
    430430
    431431        // No menus + wp_nav_menu() falls back to wp_page_menu(), this time without a container.
     
    449449
    450450        // After falling back, the markup should not include whitespace around <li>'s.
    451         $this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
     451        $this->assertDoesNotMatchRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
    452452        $this->assertMatchesRegularExpression( '/><li.*>|<\/li></U', $menu );
    453453
  • trunk/tests/phpunit/tests/query/results.php

    r51565 r51566  
    805805
    806806        $this->assertNotEmpty( $posts2 );
    807         $this->assertNotRegExp( '#AND 1=0#', $this->q->request );
     807        $this->assertDoesNotMatchRegularExpression( '#AND 1=0#', $this->q->request );
    808808    }
    809809
  • trunk/tests/phpunit/tests/query/search.php

    r51462 r51566  
    260260        );
    261261
    262         $this->assertNotRegExp( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
     262        $this->assertDoesNotMatchRegularExpression( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
    263263    }
    264264
Note: See TracChangeset for help on using the changeset viewer.