From 81b31a1bd8aa6be2c74bb2ed9e5da0b85758b2c6 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 16 Aug 2020 00:58:47 +0200 Subject: [PATCH] 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.0. The `assertMatchesRegularExpression()` and `assertDoesNotMatchRegularExpression()` methods were introduced as a replacement in PHPUnit 9.1. Ref: * https://github.com/sebastianbergmann/phpunit/blob/9.1.5/ChangeLog-9.1.md#910---2020-04-03 * https://github.com/sebastianbergmann/phpunit/issues/4085 * https://github.com/sebastianbergmann/phpunit/issues/4088 --- tests/phpunit/tests/category/wpDropdownCategories.php | 4 ++-- tests/phpunit/tests/category/wpListCategories.php | 10 +++++----- tests/phpunit/tests/menu/walker-nav-menu-edit.php | 2 +- tests/phpunit/tests/post/getPostsByAuthorSql.php | 2 +- tests/phpunit/tests/post/nav-menu.php | 4 ++-- tests/phpunit/tests/post/template.php | 6 +++--- tests/phpunit/tests/query/results.php | 2 +- tests/phpunit/tests/query/search.php | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/tests/category/wpDropdownCategories.php b/tests/phpunit/tests/category/wpDropdownCategories.php index d7e5af31b3bb..c40bd3b490f8 100644 --- a/tests/phpunit/tests/category/wpDropdownCategories.php +++ b/tests/phpunit/tests/category/wpDropdownCategories.php @@ -227,7 +227,7 @@ public function test_required_false_should_omit_required_attribute() { $dropdown_categories = wp_dropdown_categories( $args ); // Test to see if it contains the "required" attribute. - $this->assertNotRegExp( '/]+required/', $dropdown_categories ); + $this->assertDoesNotMatchRegularExpression( '/]+required/', $dropdown_categories ); } /** @@ -251,6 +251,6 @@ public function test_required_should_default_to_false() { $dropdown_categories = wp_dropdown_categories( $args ); // Test to see if it contains the "required" attribute. - $this->assertNotRegExp( '/]+required/', $dropdown_categories ); + $this->assertDoesNotMatchRegularExpression( '/]+required/', $dropdown_categories ); } } diff --git a/tests/phpunit/tests/category/wpListCategories.php b/tests/phpunit/tests/category/wpListCategories.php index 7bcc6e263e3e..eb21fbd484a3 100644 --- a/tests/phpunit/tests/category/wpListCategories.php +++ b/tests/phpunit/tests/category/wpListCategories.php @@ -29,7 +29,7 @@ public function test_class_containing_current_cat() { ) ); - $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found ); + $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found ); $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found ); } @@ -50,7 +50,7 @@ public function test_class_containing_current_cat_parent() { ); $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found ); - $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found ); + $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found ); } /** @@ -68,7 +68,7 @@ public function test_current_category_should_accept_an_array_of_ids() { ); $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found ); - $this->assertNotRegExp( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found ); + $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found ); $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found ); } @@ -652,7 +652,7 @@ public function test_class_containing_current_cat_ancestor() { $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $parent . '[^"]*current-cat-ancestor[^"]*"/', $actual ); $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $child . '[^"]*current-cat-ancestor[^"]*"/', $actual ); - $this->assertNotRegExp( '/class="[^"]*cat-item-' . $grandchild . '[^"]*current-cat-ancestor[^"]*"/', $actual ); - $this->assertNotRegExp( '/class="[^"]*cat-item-' . $child2 . '[^"]*current-cat-ancestor[^"]*"/', $actual ); + $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $grandchild . '[^"]*current-cat-ancestor[^"]*"/', $actual ); + $this->assertDoesNotMatchRegularExpression( '/class="[^"]*cat-item-' . $child2 . '[^"]*current-cat-ancestor[^"]*"/', $actual ); } } diff --git a/tests/phpunit/tests/menu/walker-nav-menu-edit.php b/tests/phpunit/tests/menu/walker-nav-menu-edit.php index 08c2f549b0ca..8c2538d92c7a 100644 --- a/tests/phpunit/tests/menu/walker-nav-menu-edit.php +++ b/tests/phpunit/tests/menu/walker-nav-menu-edit.php @@ -55,6 +55,6 @@ function test_original_title_prefix_should_not_be_shown_if_empty() { $this->walker->start_el( $expected, (object) $item ); - $this->assertNotRegExp( '#
  • 's. $this->assertMatchesRegularExpression( '/\s|<\/li>\s/U', $menu ); - $this->assertNotRegExp( '/<\/li>/U', $menu ); + $this->assertDoesNotMatchRegularExpression( '/<\/li>/U', $menu ); // Whitespace suppressed. $menu = wp_nav_menu( @@ -473,7 +473,7 @@ function test_wp_nav_menu_whitespace_options() { ); // The markup should not include whitespace around
  • 's. - $this->assertNotRegExp( '/\s|<\/li>\s/U', $menu ); + $this->assertDoesNotMatchRegularExpression( '/\s|<\/li>\s/U', $menu ); $this->assertMatchesRegularExpression( '/>|<\/li>assertNotRegExp( '/]+class=\'/', $found ); + $this->assertDoesNotMatchRegularExpression( '/]+class=\'/', $found ); } /** @@ -426,7 +426,7 @@ public function test_wp_page_menu_wp_nav_menu_fallback() { // After falling back, the markup should include whitespace around
  • 's. $this->assertMatchesRegularExpression( '/\s|<\/li>\s/U', $menu ); - $this->assertNotRegExp( '/>|<\/li>assertDoesNotMatchRegularExpression( '/>|<\/li>'s. - $this->assertNotRegExp( '/\s|<\/li>\s/U', $menu ); + $this->assertDoesNotMatchRegularExpression( '/\s|<\/li>\s/U', $menu ); $this->assertMatchesRegularExpression( '/>|<\/li>q->query( array( 'post_type' => 'any' ) ); $this->assertNotEmpty( $posts2 ); - $this->assertNotRegExp( '#AND 1=0#', $this->q->request ); + $this->assertDoesNotMatchRegularExpression( '#AND 1=0#', $this->q->request ); } /** diff --git a/tests/phpunit/tests/query/search.php b/tests/phpunit/tests/query/search.php index 12cc320df12a..b5dbe5841aec 100644 --- a/tests/phpunit/tests/query/search.php +++ b/tests/phpunit/tests/query/search.php @@ -260,7 +260,7 @@ public function test_search_orderby_should_be_empty_when_search_string_is_longer ) ); - $this->assertNotRegExp( '|ORDER BY \(CASE[^\)]+\)|', $q->request ); + $this->assertDoesNotMatchRegularExpression( '|ORDER BY \(CASE[^\)]+\)|', $q->request ); } /**