diff --git a/tests/phpunit/tests/ajax/Response.php b/tests/phpunit/tests/ajax/Response.php index 0bb3cf3fa6..731f09eb5d 100644 --- a/tests/phpunit/tests/ajax/Response.php +++ b/tests/phpunit/tests/ajax/Response.php @@ -100,6 +100,6 @@ class Tests_Ajax_Response extends WP_UnitTestCase { // Check the XML tag. $contents = ob_get_clean(); - $this->assertRegExp( '/<\?xml\s+version=\'1.0\'\s+encoding=\'' . preg_quote( get_option( 'blog_charset' ) ) . '\'\s+standalone=\'yes\'\?>/', $contents ); + $this->assertMatchesRegularExpression( '/<\?xml\s+version=\'1.0\'\s+encoding=\'' . preg_quote( get_option( 'blog_charset' ) ) . '\'\s+standalone=\'yes\'\?>/', $contents ); } } diff --git a/tests/phpunit/tests/avatar.php b/tests/phpunit/tests/avatar.php index 4867bdbf9c..336ab611e2 100644 --- a/tests/phpunit/tests/avatar.php +++ b/tests/phpunit/tests/avatar.php @@ -257,7 +257,7 @@ class Tests_Avatar extends WP_UnitTestCase { $actual_data = get_avatar_data( $comment ); $this->assertTrue( is_avatar_comment_type( $comment_type ) ); - $this->assertRegexp( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] ); + $this->assertMatchesRegularExpression( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] ); } /** diff --git a/tests/phpunit/tests/category/wpDropdownCategories.php b/tests/phpunit/tests/category/wpDropdownCategories.php index 92200a21e3..d7e5af31b3 100644 --- a/tests/phpunit/tests/category/wpDropdownCategories.php +++ b/tests/phpunit/tests/category/wpDropdownCategories.php @@ -202,7 +202,7 @@ class Tests_Category_WpDropdownCategories extends WP_UnitTestCase { $dropdown_categories = wp_dropdown_categories( $args ); // Test to see if it contains the "required" attribute. - $this->assertRegExp( '/]+required/', $dropdown_categories ); + $this->assertMatchesRegularExpression( '/]+required/', $dropdown_categories ); } /** diff --git a/tests/phpunit/tests/category/wpListCategories.php b/tests/phpunit/tests/category/wpListCategories.php index b3b5b0bafd..7bcc6e263e 100644 --- a/tests/phpunit/tests/category/wpListCategories.php +++ b/tests/phpunit/tests/category/wpListCategories.php @@ -30,7 +30,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { ); $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found ); - $this->assertRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found ); + $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found ); } public function test_class_containing_current_cat_parent() { @@ -49,7 +49,7 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { ) ); - $this->assertRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found ); + $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found ); $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found ); } @@ -67,9 +67,9 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { ) ); - $this->assertRegExp( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found ); + $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found ); $this->assertNotRegExp( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found ); - $this->assertRegExp( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found ); + $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found ); } /** @@ -650,8 +650,8 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { ) ); - $this->assertRegExp( '/class="[^"]*cat-item-' . $parent . '[^"]*current-cat-ancestor[^"]*"/', $actual ); - $this->assertRegExp( '/class="[^"]*cat-item-' . $child . '[^"]*current-cat-ancestor[^"]*"/', $actual ); + $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 ); } diff --git a/tests/phpunit/tests/comment/commentForm.php b/tests/phpunit/tests/comment/commentForm.php index 1b8c8693b4..c5cdf5849b 100644 --- a/tests/phpunit/tests/comment/commentForm.php +++ b/tests/phpunit/tests/comment/commentForm.php @@ -18,7 +18,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase { $button = ''; $hidden = get_comment_id_fields( $p ); - $this->assertRegExp( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); + $this->assertMatchesRegularExpression( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); } public function test_custom_submit_button() { @@ -53,7 +53,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase { $button = ''; $hidden = get_comment_id_fields( $p ); - $this->assertRegExp( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); + $this->assertMatchesRegularExpression( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); } /** @@ -75,7 +75,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase { $button = ''; $hidden = get_comment_id_fields( $p ); - $this->assertRegExp( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); + $this->assertMatchesRegularExpression( '|

\s*' . $button . '\s*' . $hidden . '\s*|', $form ); } public function filter_comment_form_defaults( $defaults ) { @@ -102,7 +102,7 @@ class Tests_Comment_CommentForm extends WP_UnitTestCase { remove_filter( 'option_show_comments_cookies_opt_in', '__return_true' ); - $this->assertRegExp( '|

|', $form ); + $this->assertMatchesRegularExpression( '||', $form ); } /** diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index b1c604beff..8c411a316c 100644 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -770,7 +770,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { if ( $post_types ) { foreach ( $post_types as $type ) { $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template ); - $this->assertRegExp( '#

\s*' . esc_html( $type->labels->name ) . '#', $template ); + $this->assertMatchesRegularExpression( '#

\s*' . esc_html( $type->labels->name ) . '#', $template ); $this->assertStringContainsString( 'data-type="post_type"', $template ); $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template ); $this->assertStringContainsString( 'data-type_label="' . esc_attr( $type->labels->singular_name ) . '"', $template ); @@ -781,7 +781,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { if ( $taxonomies ) { foreach ( $taxonomies as $tax ) { $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template ); - $this->assertRegExp( '#

\s*' . esc_html( $tax->labels->name ) . '#', $template ); + $this->assertMatchesRegularExpression( '#

\s*' . esc_html( $tax->labels->name ) . '#', $template ); $this->assertStringContainsString( 'data-type="taxonomy"', $template ); $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template ); $this->assertStringContainsString( 'data-type_label="' . esc_attr( $tax->labels->singular_name ) . '"', $template ); @@ -789,7 +789,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { } $this->assertStringContainsString( 'available-menu-items-custom_type', $template ); - $this->assertRegExp( '#

\s*Custom#', $template ); + $this->assertMatchesRegularExpression( '#

\s*Custom#', $template ); $this->assertStringContainsString( 'data-type="custom_type"', $template ); $this->assertStringContainsString( 'data-object="custom_object"', $template ); $this->assertStringContainsString( 'data-type_label="Custom Type"', $template ); @@ -1013,7 +1013,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { $this->assertSame( $save_action_count + 1, did_action( 'customize_save_nav_menus_created_posts' ) ); foreach ( $drafted_post_ids as $post_id ) { $this->assertSame( 'publish', get_post_status( $post_id ) ); - $this->assertRegExp( '/^auto-draft-\d+$/', get_post( $post_id )->post_name ); + $this->assertMatchesRegularExpression( '/^auto-draft-\d+$/', get_post( $post_id )->post_name ); $this->assertEmpty( get_post_meta( $post_id, '_customize_draft_post_name', true ) ); } diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index 5f183189ff..235c45c419 100644 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -610,8 +610,8 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $params = $control->json(); $this->assertSame( 'widget_form', $params['type'] ); - $this->assertRegExp( '#^]+>\s*$#', $params['content'] ); - $this->assertRegExp( '#^]*class=\'widget\'[^>]*#s', $params['widget_control'] ); + $this->assertMatchesRegularExpression( '#^]+>\s*$#', $params['content'] ); + $this->assertMatchesRegularExpression( '#^]*class=\'widget\'[^>]*#s', $params['widget_control'] ); $this->assertStringContainsString( '
', $params['widget_control'] ); $this->assertStringNotContainsString( 'assertStringContainsString( 'assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $wpdb->remove_placeholder_escape( $found ) ); + $this->assertMatchesRegularExpression( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $wpdb->remove_placeholder_escape( $found ) ); } public function test_build_time_query_hour_minute_second() { @@ -724,7 +724,7 @@ class Tests_Date_Query extends WP_UnitTestCase { // $compare value is floating point - use regex to account for // varying precision on different PHP installations. - $this->assertRegExp( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); + $this->assertMatchesRegularExpression( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); } public function test_build_time_query_minute_second() { @@ -735,7 +735,7 @@ class Tests_Date_Query extends WP_UnitTestCase { // $compare value is floating point - use regex to account for // varying precision on different PHP installations. - $this->assertRegExp( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); + $this->assertMatchesRegularExpression( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); } /** diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 06320930b9..d85ad1af40 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -1207,7 +1207,7 @@ class Tests_Functions extends WP_UnitTestCase { $ids = array(); for ( $i = 0; $i < 20; $i += 1 ) { $id = wp_unique_id( 'foo-' ); - $this->assertRegExp( '/^foo-\d+$/', $id ); + $this->assertMatchesRegularExpression( '/^foo-\d+$/', $id ); $ids[] = $id; } $this->assertSame( $ids, array_unique( $ids ) ); diff --git a/tests/phpunit/tests/meta/query.php b/tests/phpunit/tests/meta/query.php index 7dd2535a5b..bf82a66337 100644 --- a/tests/phpunit/tests/meta/query.php +++ b/tests/phpunit/tests/meta/query.php @@ -925,7 +925,7 @@ class Tests_Meta_Query extends WP_UnitTestCase { $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); // Use regex because we don't care about the whitespace before OR. - $this->assertRegExp( "/{$wpdb->postmeta}\.meta_key = \'exclude\'\s+OR/", $sql['where'] ); + $this->assertMatchesRegularExpression( "/{$wpdb->postmeta}\.meta_key = \'exclude\'\s+OR/", $sql['where'] ); $this->assertStringNotContainsString( "{$wpdb->postmeta}.post_id IS NULL", $sql['where'] ); } diff --git a/tests/phpunit/tests/post/getPostsByAuthorSql.php b/tests/phpunit/tests/post/getPostsByAuthorSql.php index f030738f0d..2c337320e5 100644 --- a/tests/phpunit/tests/post/getPostsByAuthorSql.php +++ b/tests/phpunit/tests/post/getPostsByAuthorSql.php @@ -34,7 +34,7 @@ class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase { public function test_full_true() { $maybe_string = get_posts_by_author_sql( 'post', true ); - $this->assertRegExp( '/^WHERE /', $maybe_string ); + $this->assertMatchesRegularExpression( '/^WHERE /', $maybe_string ); } public function test_full_false() { diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 08241af64e..902670bf49 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -460,7 +460,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { ); // The markup should include whitespace between
  • 's. - $this->assertRegExp( '/\s|<\/li>\s/U', $menu ); + $this->assertMatchesRegularExpression( '/\s|<\/li>\s/U', $menu ); $this->assertNotRegExp( '/<\/li>/U', $menu ); // Whitespace suppressed. @@ -474,7 +474,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { // The markup should not include whitespace around
  • 's. $this->assertNotRegExp( '/\s|<\/li>\s/U', $menu ); - $this->assertRegExp( '/>|<\/li>assertMatchesRegularExpression( '/>|<\/li>assertRegExp( '/]+class=\'bar\'/', $found ); + $this->assertMatchesRegularExpression( '/]+class=\'bar\'/', $found ); } /** @@ -419,13 +419,13 @@ NO; $menu = wp_nav_menu( array( 'echo' => false ) ); // After falling back, the 'before' argument should be set and output as '
      '. - $this->assertRegExp( '/