mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
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 * https://github.com/sebastianbergmann/phpunit/issues/4085 * https://github.com/sebastianbergmann/phpunit/issues/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
This commit is contained in:
@@ -227,7 +227,7 @@ class Tests_Category_WpDropdownCategories extends WP_UnitTestCase {
|
||||
$dropdown_categories = wp_dropdown_categories( $args );
|
||||
|
||||
// Test to see if it contains the "required" attribute.
|
||||
$this->assertNotRegExp( '/<select[^>]+required/', $dropdown_categories );
|
||||
$this->assertDoesNotMatchRegularExpression( '/<select[^>]+required/', $dropdown_categories );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,6 +251,6 @@ class Tests_Category_WpDropdownCategories extends WP_UnitTestCase {
|
||||
$dropdown_categories = wp_dropdown_categories( $args );
|
||||
|
||||
// Test to see if it contains the "required" attribute.
|
||||
$this->assertNotRegExp( '/<select[^>]+required/', $dropdown_categories );
|
||||
$this->assertDoesNotMatchRegularExpression( '/<select[^>]+required/', $dropdown_categories );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$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 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$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 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$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 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase {
|
||||
|
||||
$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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,6 @@ class Tests_Menu_Walker_Nav_Menu_Edit extends WP_UnitTestCase {
|
||||
|
||||
$this->walker->start_el( $expected, (object) $item );
|
||||
|
||||
$this->assertNotRegExp( '#<p class="link-to-original">\s*Original: <a href=""></a>#', $expected );
|
||||
$this->assertDoesNotMatchRegularExpression( '#<p class="link-to-original">\s*Original: <a href=""></a>#', $expected );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
|
||||
|
||||
public function test_full_false() {
|
||||
$maybe_string = get_posts_by_author_sql( 'post', false );
|
||||
$this->assertNotRegExp( '/^WHERE /', $maybe_string );
|
||||
$this->assertDoesNotMatchRegularExpression( '/^WHERE /', $maybe_string );
|
||||
}
|
||||
|
||||
public function test_post_type_clause_should_be_included_when_full_is_true() {
|
||||
|
||||
@@ -461,7 +461,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
|
||||
|
||||
// The markup should include whitespace between <li>'s.
|
||||
$this->assertMatchesRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertNotRegExp( '/<\/li><li.*>/U', $menu );
|
||||
$this->assertDoesNotMatchRegularExpression( '/<\/li><li.*>/U', $menu );
|
||||
|
||||
// Whitespace suppressed.
|
||||
$menu = wp_nav_menu(
|
||||
@@ -473,7 +473,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
// The markup should not include whitespace around <li>'s.
|
||||
$this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertDoesNotMatchRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertMatchesRegularExpression( '/><li.*>|<\/li></U', $menu );
|
||||
}
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ NO;
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNotRegExp( '/<select[^>]+class=\'/', $found );
|
||||
$this->assertDoesNotMatchRegularExpression( '/<select[^>]+class=\'/', $found );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,7 +426,7 @@ NO;
|
||||
|
||||
// After falling back, the markup should include whitespace around <li>'s.
|
||||
$this->assertMatchesRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertNotRegExp( '/><li.*>|<\/li></U', $menu );
|
||||
$this->assertDoesNotMatchRegularExpression( '/><li.*>|<\/li></U', $menu );
|
||||
|
||||
// No menus + wp_nav_menu() falls back to wp_page_menu(), this time without a container.
|
||||
$menu = wp_nav_menu(
|
||||
@@ -448,7 +448,7 @@ NO;
|
||||
);
|
||||
|
||||
// After falling back, the markup should not include whitespace around <li>'s.
|
||||
$this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertDoesNotMatchRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu );
|
||||
$this->assertMatchesRegularExpression( '/><li.*>|<\/li></U', $menu );
|
||||
|
||||
}
|
||||
|
||||
@@ -804,7 +804,7 @@ class Tests_Query_Results extends WP_UnitTestCase {
|
||||
$posts2 = $this->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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -259,7 +259,7 @@ class Tests_Query_Search extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertNotRegExp( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
|
||||
$this->assertDoesNotMatchRegularExpression( '|ORDER BY \(CASE[^\)]+\)|', $q->request );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user