Changeset 51565
- Timestamp:
- 08/06/2021 09:52:06 PM (3 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/Response.php
r51404 r51565 101 101 // Check the XML tag. 102 102 $contents = ob_get_clean(); 103 $this->assert RegExp( '/<\?xml\s+version=\'1.0\'\s+encoding=\'' . preg_quote( get_option( 'blog_charset' ) ) . '\'\s+standalone=\'yes\'\?>/', $contents );103 $this->assertMatchesRegularExpression( '/<\?xml\s+version=\'1.0\'\s+encoding=\'' . preg_quote( get_option( 'blog_charset' ) ) . '\'\s+standalone=\'yes\'\?>/', $contents ); 104 104 } 105 105 } -
trunk/tests/phpunit/tests/avatar.php
r48937 r51565 258 258 259 259 $this->assertTrue( is_avatar_comment_type( $comment_type ) ); 260 $this->assert Regexp( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] );260 $this->assertMatchesRegularExpression( '|^http?://[0-9]+.gravatar.com/avatar/[0-9a-f]{32}\?|', $actual_data['url'] ); 261 261 } 262 262 -
trunk/tests/phpunit/tests/category/wpDropdownCategories.php
r51462 r51565 203 203 204 204 // Test to see if it contains the "required" attribute. 205 $this->assert RegExp( '/<select[^>]+required/', $dropdown_categories );205 $this->assertMatchesRegularExpression( '/<select[^>]+required/', $dropdown_categories ); 206 206 } 207 207 -
trunk/tests/phpunit/tests/category/wpListCategories.php
r51462 r51565 31 31 32 32 $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found ); 33 $this->assert RegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found );33 $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found ); 34 34 } 35 35 … … 50 50 ); 51 51 52 $this->assert RegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found );52 $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found ); 53 53 $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found ); 54 54 } … … 68 68 ); 69 69 70 $this->assert RegExp( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found );70 $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[0] . '[^"]*current-cat[^"]*"/', $found ); 71 71 $this->assertNotRegExp( '/class="[^"]*cat-item-' . $cats[1] . '[^"]*current[^"]*"/', $found ); 72 $this->assert RegExp( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found );72 $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $cats[2] . '[^"]*current-cat[^"]*"/', $found ); 73 73 } 74 74 … … 651 651 ); 652 652 653 $this->assert RegExp( '/class="[^"]*cat-item-' . $parent . '[^"]*current-cat-ancestor[^"]*"/', $actual );654 $this->assert RegExp( '/class="[^"]*cat-item-' . $child . '[^"]*current-cat-ancestor[^"]*"/', $actual );653 $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $parent . '[^"]*current-cat-ancestor[^"]*"/', $actual ); 654 $this->assertMatchesRegularExpression( '/class="[^"]*cat-item-' . $child . '[^"]*current-cat-ancestor[^"]*"/', $actual ); 655 655 $this->assertNotRegExp( '/class="[^"]*cat-item-' . $grandchild . '[^"]*current-cat-ancestor[^"]*"/', $actual ); 656 656 $this->assertNotRegExp( '/class="[^"]*cat-item-' . $child2 . '[^"]*current-cat-ancestor[^"]*"/', $actual ); -
trunk/tests/phpunit/tests/comment/commentForm.php
r51462 r51565 19 19 $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />'; 20 20 $hidden = get_comment_id_fields( $p ); 21 $this->assert RegExp( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form );21 $this->assertMatchesRegularExpression( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form ); 22 22 } 23 23 … … 54 54 $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />'; 55 55 $hidden = get_comment_id_fields( $p ); 56 $this->assert RegExp( '|<p class="my\-custom\-submit\-field">\s*' . $button . '\s*' . $hidden . '\s*|', $form );56 $this->assertMatchesRegularExpression( '|<p class="my\-custom\-submit\-field">\s*' . $button . '\s*' . $hidden . '\s*|', $form ); 57 57 } 58 58 … … 76 76 $button = '<input name="foo-name" type="submit" id="foo-id" class="foo-class" value="foo-label" />'; 77 77 $hidden = get_comment_id_fields( $p ); 78 $this->assert RegExp( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form );78 $this->assertMatchesRegularExpression( '|<p class="form\-submit">\s*' . $button . '\s*' . $hidden . '\s*|', $form ); 79 79 } 80 80 … … 103 103 remove_filter( 'option_show_comments_cookies_opt_in', '__return_true' ); 104 104 105 $this->assert RegExp( '|<p class="comment\-form\-cookies\-consent">.*?</p>|', $form );105 $this->assertMatchesRegularExpression( '|<p class="comment\-form\-cookies\-consent">.*?</p>|', $form ); 106 106 } 107 107 -
trunk/tests/phpunit/tests/customize/nav-menus.php
r51462 r51565 771 771 foreach ( $post_types as $type ) { 772 772 $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template ); 773 $this->assert RegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template );773 $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template ); 774 774 $this->assertStringContainsString( 'data-type="post_type"', $template ); 775 775 $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template ); … … 782 782 foreach ( $taxonomies as $tax ) { 783 783 $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template ); 784 $this->assert RegExp( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template );784 $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template ); 785 785 $this->assertStringContainsString( 'data-type="taxonomy"', $template ); 786 786 $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template ); … … 790 790 791 791 $this->assertStringContainsString( 'available-menu-items-custom_type', $template ); 792 $this->assert RegExp( '#<h4 class="accordion-section-title".*>\s*Custom#', $template );792 $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*Custom#', $template ); 793 793 $this->assertStringContainsString( 'data-type="custom_type"', $template ); 794 794 $this->assertStringContainsString( 'data-object="custom_object"', $template ); … … 1014 1014 foreach ( $drafted_post_ids as $post_id ) { 1015 1015 $this->assertSame( 'publish', get_post_status( $post_id ) ); 1016 $this->assert RegExp( '/^auto-draft-\d+$/', get_post( $post_id )->post_name );1016 $this->assertMatchesRegularExpression( '/^auto-draft-\d+$/', get_post( $post_id )->post_name ); 1017 1017 $this->assertEmpty( get_post_meta( $post_id, '_customize_draft_post_name', true ) ); 1018 1018 } -
trunk/tests/phpunit/tests/customize/widgets.php
r51462 r51565 611 611 612 612 $this->assertSame( 'widget_form', $params['type'] ); 613 $this->assert RegExp( '#^<li[^>]+>\s*</li>$#', $params['content'] );614 $this->assert RegExp( '#^<div[^>]*class=\'widget\'[^>]*#s', $params['widget_control'] );613 $this->assertMatchesRegularExpression( '#^<li[^>]+>\s*</li>$#', $params['content'] ); 614 $this->assertMatchesRegularExpression( '#^<div[^>]*class=\'widget\'[^>]*#s', $params['widget_control'] ); 615 615 $this->assertStringContainsString( '<div class="widget-content"></div>', $params['widget_control'] ); 616 616 $this->assertStringNotContainsString( '<input class="widefat"', $params['widget_control'] ); -
trunk/tests/phpunit/tests/date/query.php
r51462 r51565 714 714 // $compare value is floating point - use regex to account for 715 715 // varying precision on different PHP installations. 716 $this->assert RegExp( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $wpdb->remove_placeholder_escape( $found ) );716 $this->assertMatchesRegularExpression( "/DATE_FORMAT\( post_date, '%H\.%i' \) = 5\.150*/", $wpdb->remove_placeholder_escape( $found ) ); 717 717 } 718 718 … … 725 725 // $compare value is floating point - use regex to account for 726 726 // varying precision on different PHP installations. 727 $this->assert RegExp( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $wpdb->remove_placeholder_escape( $found ) );727 $this->assertMatchesRegularExpression( "/DATE_FORMAT\( post_date, '%H\.%i%s' \) = 5\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); 728 728 } 729 729 … … 736 736 // $compare value is floating point - use regex to account for 737 737 // varying precision on different PHP installations. 738 $this->assert RegExp( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $wpdb->remove_placeholder_escape( $found ) );738 $this->assertMatchesRegularExpression( "/DATE_FORMAT\( post_date, '0\.%i%s' \) = 0\.15350*/", $wpdb->remove_placeholder_escape( $found ) ); 739 739 } 740 740 -
trunk/tests/phpunit/tests/functions.php
r51564 r51565 1208 1208 for ( $i = 0; $i < 20; $i += 1 ) { 1209 1209 $id = wp_unique_id( 'foo-' ); 1210 $this->assert RegExp( '/^foo-\d+$/', $id );1210 $this->assertMatchesRegularExpression( '/^foo-\d+$/', $id ); 1211 1211 $ids[] = $id; 1212 1212 } -
trunk/tests/phpunit/tests/meta/query.php
r51462 r51565 926 926 927 927 // Use regex because we don't care about the whitespace before OR. 928 $this->assert RegExp( "/{$wpdb->postmeta}\.meta_key = \'exclude\'\s+OR/", $sql['where'] );928 $this->assertMatchesRegularExpression( "/{$wpdb->postmeta}\.meta_key = \'exclude\'\s+OR/", $sql['where'] ); 929 929 $this->assertStringNotContainsString( "{$wpdb->postmeta}.post_id IS NULL", $sql['where'] ); 930 930 } -
trunk/tests/phpunit/tests/post/getPostsByAuthorSql.php
r51462 r51565 35 35 public function test_full_true() { 36 36 $maybe_string = get_posts_by_author_sql( 'post', true ); 37 $this->assert RegExp( '/^WHERE /', $maybe_string );37 $this->assertMatchesRegularExpression( '/^WHERE /', $maybe_string ); 38 38 } 39 39 -
trunk/tests/phpunit/tests/post/nav-menu.php
r51449 r51565 461 461 462 462 // The markup should include whitespace between <li>'s. 463 $this->assert RegExp( '/\s<li.*>|<\/li>\s/U', $menu );463 $this->assertMatchesRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu ); 464 464 $this->assertNotRegExp( '/<\/li><li.*>/U', $menu ); 465 465 … … 475 475 // The markup should not include whitespace around <li>'s. 476 476 $this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu ); 477 $this->assert RegExp( '/><li.*>|<\/li></U', $menu );477 $this->assertMatchesRegularExpression( '/><li.*>|<\/li></U', $menu ); 478 478 } 479 479 -
trunk/tests/phpunit/tests/post/template.php
r51462 r51565 341 341 ); 342 342 343 $this->assert RegExp( '/<select[^>]+class=\'bar\'/', $found );343 $this->assertMatchesRegularExpression( '/<select[^>]+class=\'bar\'/', $found ); 344 344 } 345 345 … … 420 420 421 421 // After falling back, the 'before' argument should be set and output as '<ul>'. 422 $this->assert RegExp( '/<div class="menu"><ul>/', $menu );422 $this->assertMatchesRegularExpression( '/<div class="menu"><ul>/', $menu ); 423 423 424 424 // After falling back, the 'after' argument should be set and output as '</ul>'. 425 $this->assert RegExp( '/<\/ul><\/div>/', $menu );425 $this->assertMatchesRegularExpression( '/<\/ul><\/div>/', $menu ); 426 426 427 427 // After falling back, the markup should include whitespace around <li>'s. 428 $this->assert RegExp( '/\s<li.*>|<\/li>\s/U', $menu );428 $this->assertMatchesRegularExpression( '/\s<li.*>|<\/li>\s/U', $menu ); 429 429 $this->assertNotRegExp( '/><li.*>|<\/li></U', $menu ); 430 430 … … 438 438 439 439 // After falling back, the empty 'container' argument should still return a container element. 440 $this->assert RegExp( '/<div class="menu">/', $menu );440 $this->assertMatchesRegularExpression( '/<div class="menu">/', $menu ); 441 441 442 442 // No menus + wp_nav_menu() falls back to wp_page_menu(), this time without white-space. … … 450 450 // After falling back, the markup should not include whitespace around <li>'s. 451 451 $this->assertNotRegExp( '/\s<li.*>|<\/li>\s/U', $menu ); 452 $this->assert RegExp( '/><li.*>|<\/li></U', $menu );452 $this->assertMatchesRegularExpression( '/><li.*>|<\/li></U', $menu ); 453 453 454 454 } -
trunk/tests/phpunit/tests/query/results.php
r51462 r51565 796 796 797 797 $this->assertEmpty( $posts ); 798 $this->assert RegExp( '#AND 1=0#', $this->q->request );798 $this->assertMatchesRegularExpression( '#AND 1=0#', $this->q->request ); 799 799 800 800 foreach ( array_keys( $wp_post_types ) as $slug ) { -
trunk/tests/phpunit/tests/term/wpGenerateTagCloud.php
r51462 r51565 130 130 ); 131 131 132 $this->assert RegExp( "|^<ul class='wp-tag-cloud' role='list'>|", $found );133 $this->assert RegExp( "|</ul>\n|", $found );132 $this->assertMatchesRegularExpression( "|^<ul class='wp-tag-cloud' role='list'>|", $found ); 133 $this->assertMatchesRegularExpression( "|</ul>\n|", $found ); 134 134 $this->assertStringContainsString( '>' . $tags[0]->name . '<', $found ); 135 135 } … … 185 185 ); 186 186 187 $this->assert RegExp( "|^<ul class='wp-tag-cloud' role='list'>|", $found );188 $this->assert RegExp( "|</ul>\n|", $found );187 $this->assertMatchesRegularExpression( "|^<ul class='wp-tag-cloud' role='list'>|", $found ); 188 $this->assertMatchesRegularExpression( "|</ul>\n|", $found ); 189 189 190 190 foreach ( $tags as $tag ) { -
trunk/tests/phpunit/tests/widgets.php
r51462 r51565 799 799 unregister_widget( 'WP_Widget_Text' ); 800 800 801 $this->assert RegExp( '/<span class="special widget_text">/', $actual );801 $this->assertMatchesRegularExpression( '/<span class="special widget_text">/', $actual ); 802 802 803 803 }
Note: See TracChangeset
for help on using the changeset viewer.