Skip to content

Commit ee2770b

Browse files
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: * https://github.com/sebastianbergmann/phpunit/blob/9.1.5/ChangeLog-9.1.md#910---2020-04-03 * sebastianbergmann/phpunit#4085 * sebastianbergmann/phpunit#4088 Follow-up to [51559-51565]. Props jrf. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51566 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 457b7b3 commit ee2770b

File tree

8 files changed

+16
-16
lines changed

8 files changed

+16
-16
lines changed

tests/phpunit/tests/category/wpDropdownCategories.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function test_required_false_should_omit_required_attribute() {
227227
$dropdown_categories = wp_dropdown_categories( $args );
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

233233
/**
@@ -251,6 +251,6 @@ public function test_required_should_default_to_false() {
251251
$dropdown_categories = wp_dropdown_categories( $args );
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
}

tests/phpunit/tests/category/wpListCategories.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function test_class_containing_current_cat() {
2929
)
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
}
3535

@@ -50,7 +50,7 @@ public function test_class_containing_current_cat_parent() {
5050
);
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

5656
/**
@@ -68,7 +68,7 @@ public function test_current_category_should_accept_an_array_of_ids() {
6868
);
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
}
7474

@@ -652,7 +652,7 @@ public function test_class_containing_current_cat_ancestor() {
652652

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
}

tests/phpunit/tests/menu/walker-nav-menu-edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ function test_original_title_prefix_should_not_be_shown_if_empty() {
5555

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
}

tests/phpunit/tests/post/getPostsByAuthorSql.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function test_full_true() {
3939

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

4545
public function test_post_type_clause_should_be_included_when_full_is_true() {

tests/phpunit/tests/post/nav-menu.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ function test_wp_nav_menu_whitespace_options() {
461461

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.
467467
$menu = wp_nav_menu(
@@ -473,7 +473,7 @@ function test_wp_nav_menu_whitespace_options() {
473473
);
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
}
479479

tests/phpunit/tests/post/template.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ public function test_wp_dropdown_pages_should_not_contain_class_attribute_when_n
319319
)
320320
);
321321

322-
$this->assertNotRegExp( '/<select[^>]+class=\'/', $found );
322+
$this->assertDoesNotMatchRegularExpression( '/<select[^>]+class=\'/', $found );
323323
}
324324

325325
/**
@@ -426,7 +426,7 @@ public function test_wp_page_menu_wp_nav_menu_fallback() {
426426

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.
432432
$menu = wp_nav_menu(
@@ -448,7 +448,7 @@ public function test_wp_page_menu_wp_nav_menu_fallback() {
448448
);
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

454454
}

tests/phpunit/tests/query/results.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ function test_exclude_from_search_empty() {
804804
$posts2 = $this->q->query( array( 'post_type' => 'any' ) );
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

810810
/**

tests/phpunit/tests/query/search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function test_search_orderby_should_be_empty_when_search_string_is_longer
259259
)
260260
);
261261

262-
$this->assertNotRegExp( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
262+
$this->assertDoesNotMatchRegularExpression( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
263263
}
264264

265265
/**

0 commit comments

Comments
 (0)