Make WordPress Core

Changeset 60251


Ignore:
Timestamp:
05/26/2025 12:03:18 PM (18 months ago)
Author:
johnbillion
Message:

Build/Test Tools: Add assertions that test the tests.

Several tests perform assertions conditionally or iterate dynamic arrays without ensuring they're populated. If the test is faulty and the condition never evaluates to true, or the array being iterated is unexpectedly empty, this will now correctly cause the test to fail.

Props johnbillion, jrf.

See #63167

Location:
trunk/tests/phpunit/tests
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment.php

    r60250 r60251  
    15671567                $lengths = wp_get_comment_fields_max_lengths();
    15681568
     1569                $this->assertNotEmpty( $lengths );
     1570
    15691571                foreach ( $lengths as $field => $length ) {
    15701572                        $this->assertSame( $expected[ $field ], $length );
  • trunk/tests/phpunit/tests/comment/commentsTemplate.php

    r56971 r60251  
    567567                preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p1, $matches );
    568568
     569                $this->assertNotEmpty( $matches );
     570                $this->assertNotEmpty( $matches[1] );
     571
    569572                // This is the main post page, so we don't expect any cpage param.
    570573                foreach ( $matches[1] as $m ) {
    … …  
    587590                preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p2, $matches );
    588591
     592                $this->assertNotEmpty( $matches );
     593                $this->assertNotEmpty( $matches[1] );
     594
    589595                // They should all be on page 2.
    590596                foreach ( $matches[1] as $m ) {
    … …  
    660666                preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p0, $matches );
    661667
     668                $this->assertNotEmpty( $matches );
     669                $this->assertNotEmpty( $matches[1] );
     670
    662671                foreach ( $matches[1] as $m ) {
    663672                        $this->assertStringContainsString( 'cpage=3', $m );
    … …  
    678687                // Find the comment permalinks.
    679688                preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p2, $matches );
     689
     690                $this->assertNotEmpty( $matches );
     691                $this->assertNotEmpty( $matches[1] );
    680692
    681693                // They should all be on page 2.
    … …  
    699711                // Find the comment permalinks.
    700712                preg_match_all( '|href="(.*?#comment-([0-9]+))|', $found_p1, $matches );
     713
     714                $this->assertNotEmpty( $matches );
     715                $this->assertNotEmpty( $matches[1] );
    701716
    702717                // They should all be on page 2.
  • trunk/tests/phpunit/tests/comment/metaCache.php

    r57685 r60251  
    196196                $this->go_to( get_permalink( $p ) );
    197197
    198                 if ( have_posts() ) {
    199                         while ( have_posts() ) {
    200                                 the_post();
    201 
    202                                 // Load comments with `comments_template()`.
    203                                 $cform = get_echo( 'comments_template' );
    204 
    205                                 // First request will hit the database.
    206                                 $num_queries = get_num_queries();
    207                                 get_comment_meta( $comment_ids[0], 'sauce' );
    208                                 $this->assertSame( 1, get_num_queries() - $num_queries );
    209 
    210                                 // Second and third requests should be in cache.
    211                                 get_comment_meta( $comment_ids[1], 'sauce' );
    212                                 get_comment_meta( $comment_ids[2], 'sauce' );
    213                                 $this->assertSame( 1, get_num_queries() - $num_queries );
    214                         }
     198                $this->assertTrue( have_posts() );
     199
     200                while ( have_posts() ) {
     201                        the_post();
     202
     203                        // Load comments with `comments_template()`.
     204                        $cform = get_echo( 'comments_template' );
     205
     206                        // First request will hit the database.
     207                        $num_queries = get_num_queries();
     208                        get_comment_meta( $comment_ids[0], 'sauce' );
     209                        $this->assertSame( 1, get_num_queries() - $num_queries );
     210
     211                        // Second and third requests should be in cache.
     212                        get_comment_meta( $comment_ids[1], 'sauce' );
     213                        get_comment_meta( $comment_ids[2], 'sauce' );
     214                        $this->assertSame( 1, get_num_queries() - $num_queries );
    215215                }
    216216        }
  • trunk/tests/phpunit/tests/customize/nav-menus.php

    r59224 r60251  
    767767
    768768                $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' );
    769                 if ( $post_types ) {
    770                         foreach ( $post_types as $type ) {
    771                                 $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
    772                                 $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $type->labels->name ) . '#', $template );
    773                                 $this->assertStringContainsString( 'data-type="post_type"', $template );
    774                                 $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template );
    775                                 $this->assertStringContainsString( 'data-type_label="' . esc_attr( $type->labels->singular_name ) . '"', $template );
    776                         }
     769
     770                $this->assertNotEmpty( $post_types );
     771
     772                foreach ( $post_types as $type ) {
     773                        $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template );
     774                        $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $type->labels->name ) . '#', $template );
     775                        $this->assertStringContainsString( 'data-type="post_type"', $template );
     776                        $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template );
     777                        $this->assertStringContainsString( 'data-type_label="' . esc_attr( $type->labels->singular_name ) . '"', $template );
    777778                }
    778779
    779780                $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' );
    780                 if ( $taxonomies ) {
    781                         foreach ( $taxonomies as $tax ) {
    782                                 $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
    783                                 $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $tax->labels->name ) . '#', $template );
    784                                 $this->assertStringContainsString( 'data-type="taxonomy"', $template );
    785                                 $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
    786                                 $this->assertStringContainsString( 'data-type_label="' . esc_attr( $tax->labels->singular_name ) . '"', $template );
    787                         }
     781
     782                $this->assertNotEmpty( $taxonomies );
     783
     784                foreach ( $taxonomies as $tax ) {
     785                        $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template );
     786                        $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*<button type="button" class="accordion-trigger" aria-expanded="false" aria-controls=".*">\s*' . esc_html( $tax->labels->name ) . '#', $template );
     787                        $this->assertStringContainsString( 'data-type="taxonomy"', $template );
     788                        $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template );
     789                        $this->assertStringContainsString( 'data-type_label="' . esc_attr( $tax->labels->singular_name ) . '"', $template );
    788790                }
    789791
  • trunk/tests/phpunit/tests/db/charset.php

    r57926 r60251  
    830830                self::$_wpdb->query( $create );
    831831
     832                $this->assertNotEmpty( $expected_charset );
     833
    832834                foreach ( $expected_charset as $column => $charset ) {
    833835                        if ( self::$utf8_is_utf8mb3 && 'utf8' === $charset ) {
    … …  
    855857                self::$_wpdb->query( $create );
    856858
     859                $this->assertNotEmpty( $columns );
     860
    857861                $columns = array_keys( $columns );
    858862                foreach ( $columns as $column => $charset ) {
    … …  
    877881
    878882                self::$_wpdb->query( $create );
     883
     884                $this->assertNotEmpty( $columns );
    879885
    880886                $columns = array_keys( $columns );
    … …  
    10711077                );
    10721078
     1079                $this->assertNotEmpty( $always_true );
     1080
    10731081                foreach ( $always_true as $true_query ) {
    10741082                        $return = self::$_wpdb->check_safe_collation( $true_query );
  • trunk/tests/phpunit/tests/feed/atom.php

    r56549 r60251  
    280280                $entries = array_slice( $entries, 0, 1 );
    281281
     282                $this->assertNotEmpty( $entries );
     283
    282284                foreach ( $entries as $key => $entry ) {
    283285                        $links = xml_find( $entries[ $key ]['child'], 'link' );
  • trunk/tests/phpunit/tests/feed/rss2.php

    r56746 r60251  
    290290                $items = xml_find( $xml, 'rss', 'channel', 'item' );
    291291
     292                $this->assertNotEmpty( $items );
     293
    292294                // Check each of the items against the known post data.
    293295                foreach ( $items as $key => $item ) {
  • trunk/tests/phpunit/tests/file.php

    r56559 r60251  
    4141                );
    4242
     43                $this->assertNotEmpty( $actual );
     44
    4345                foreach ( $actual as $header => $value ) {
    4446                        $this->assertSame( $expected[ $header ], $value, $header );
    … …  
    6567                );
    6668
     69                $this->assertNotEmpty( $actual );
     70
    6771                foreach ( $actual as $header => $value ) {
    6872                        $this->assertSame( $expected[ $header ], $value, $header );
    … …  
    8488                        'TemplateName' => 'Something',
    8589                );
     90
     91                $this->assertNotEmpty( $actual );
    8692
    8793                foreach ( $actual as $header => $value ) {
  • trunk/tests/phpunit/tests/formatting/escUrl.php

    r57987 r60251  
    125125                );
    126126
    127                 foreach ( wp_allowed_protocols() as $scheme ) {
     127                $protocols = wp_allowed_protocols();
     128
     129                $this->assertNotEmpty( $protocols );
     130
     131                foreach ( $protocols as $scheme ) {
    128132                        $this->assertSame( "{$scheme}://example.com", esc_url( "{$scheme}://example.com" ), $scheme );
    129133                        $this->assertSame(
  • trunk/tests/phpunit/tests/formatting/sanitizePost.php

    r54728 r60251  
    3030                                        $this->assertIsString( $post->$field, "field $field" );
    3131                                        break;
     32                                default:
     33                                        $this->fail( "Type $type is not handled by this test." );
     34                                        break;
    3235                        }
    3336                }
  • trunk/tests/phpunit/tests/formatting/wpSpecialchars.php

    r53562 r60251  
    1717        public function test_allowed_entity_names() {
    1818                global $allowedentitynames;
     19
     20                $this->assertNotEmpty( $allowedentitynames );
    1921
    2022                // Allowed entities should be unchanged.
  • trunk/tests/phpunit/tests/formatting/wpTrimExcerpt.php

    r56693 r60251  
    3030                        )
    3131                );
    32                 if ( $q->have_posts() ) {
    33                         while ( $q->have_posts() ) {
    34                                 $q->the_post();
    35                                 $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
    36                         }
     32
     33                $this->assertTrue( $q->have_posts() );
     34
     35                while ( $q->have_posts() ) {
     36                        $q->the_post();
     37                        $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
    3738                }
    3839        }
    … …  
    6162                        )
    6263                );
    63                 if ( $q->have_posts() ) {
    64                         while ( $q->have_posts() ) {
    65                                 $q->the_post();
    66                                 $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
    67                         }
     64
     65                $this->assertTrue( $q->have_posts() );
     66
     67                while ( $q->have_posts() ) {
     68                        $q->the_post();
     69                        $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
    6870                }
    6971        }
  • trunk/tests/phpunit/tests/functions.php

    r59379 r60251  
    11451145        public function test_wp_ext2type() {
    11461146                $extensions = wp_get_ext_types();
     1147
     1148                $this->assertNotEmpty( $extensions );
    11471149
    11481150                foreach ( $extensions as $type => $extension_list ) {
  • trunk/tests/phpunit/tests/kses.php

    r59677 r60251  
    490490                $tags = wp_kses_allowed_html( 'post' );
    491491
     492                $this->assertNotEmpty( $tags );
     493
    492494                foreach ( $tags as $tag ) {
    493495                        $this->assertTrue( $tag['class'] );
  • trunk/tests/phpunit/tests/media.php

    r59987 r60251  
    18471847                // Calculate a srcset array.
    18481848                $sizes = explode( ', ', wp_calculate_image_srcset( $size_array, $image_url, $image_meta ) );
     1849
     1850                $this->assertNotEmpty( $sizes );
    18491851
    18501852                // Test to confirm all sources in the array include the same edit hash.
    … …  
    37813783                $query = $this->get_new_wp_query_for_published_post();
    37823784
     3785                $this->assertTrue( have_posts() );
     3786
    37833787                while ( have_posts() ) {
    37843788                        the_post();
    … …  
    38373841                // Use the filter to alter the threshold for not lazy-loading to the first five elements.
    38383842                $this->force_omit_loading_attr_threshold( 5 );
     3843
     3844                $this->assertTrue( have_posts() );
    38393845
    38403846                while ( have_posts() ) {
  • trunk/tests/phpunit/tests/meta.php

    r58968 r60251  
    107107                $found              = $this->updated_mids;
    108108                $this->updated_mids = array();
     109
     110                $this->assertNotEmpty( $found );
    109111
    110112                foreach ( $found as $action => $mids ) {
  • trunk/tests/phpunit/tests/post.php

    r57239 r60251  
    270270                $term  = reset( $terms );
    271271
     272                $this->assertNotEmpty( $matches );
     273                $this->assertNotEmpty( $matches[1] );
     274
    272275                foreach ( $matches[1] as $url ) {
    273276                        $this->assertStringContainsString( 'tag_ID=' . $term->term_id, $url );
  • trunk/tests/phpunit/tests/post/revisions.php

    r56559 r60251  
    230230                $this->assertCount( 1, $revisions );
    231231                $this->assertTrue( user_can( self::$editor_user_id, 'read_post', $post_id ) );
     232
     233                $this->assertNotEmpty( $revisions );
    232234
    233235                foreach ( $revisions as $revision ) {
  • trunk/tests/phpunit/tests/post/wpPostType.php

    r58211 r60251  
    77        public function test_instances() {
    88                global $wp_post_types;
     9
     10                $this->assertNotEmpty( $wp_post_types );
    911
    1012                foreach ( $wp_post_types as $post_type ) {
  • trunk/tests/phpunit/tests/query.php

    r56559 r60251  
    1818
    1919                $first_query = new WP_Query( array( 'post__in' => array( $post_id ) ) );
     20
     21                $this->assertTrue( $first_query->have_posts() );
     22
    2023                while ( $first_query->have_posts() ) {
    2124                        $first_query->the_post();
  • trunk/tests/phpunit/tests/query/postStatus.php

    r54865 r60251  
    241241                );
    242242
    243                 foreach ( get_post_stati( array( 'public' => true ) ) as $status ) {
     243                $stati = get_post_stati( array( 'public' => true ) );
     244
     245                $this->assertNotEmpty( $stati );
     246
     247                foreach ( $stati as $status ) {
    244248                        $this->assertStringContainsString( "post_status = '$status'", $q->request );
    245249                }
  • trunk/tests/phpunit/tests/query/setupPostdata.php

    r54891 r60251  
    122122                        )
    123123                );
     124
     125                $this->assertTrue( $q->have_posts() );
     126
    124127                if ( $q->have_posts() ) {
    125128                        while ( $q->have_posts() ) {
    … …  
    222225                        )
    223226                );
     227
     228                $this->assertTrue( $q->have_posts() );
     229
    224230                if ( $q->have_posts() ) {
    225231                        while ( $q->have_posts() ) {
    … …  
    282288                        )
    283289                );
     290
     291                $this->assertTrue( $q->have_posts() );
     292
    284293                if ( $q->have_posts() ) {
    285294                        while ( $q->have_posts() ) {
    … …  
    368377                        )
    369378                );
     379
     380                $this->assertTrue( $q->have_posts() );
     381
    370382                if ( $q->have_posts() ) {
    371383                        while ( $q->have_posts() ) {
  • trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php

    r59970 r60251  
    34433443                        $this->assertSame( $comment->comment_agent, $data['author_user_agent'] );
    34443444                        $this->assertSame( $comment->comment_content, $data['content']['raw'] );
    3445                 }
    3446 
    3447                 if ( 'edit' !== $context ) {
     3445                } else {
    34483446                        $this->assertArrayNotHasKey( 'author_email', $data );
    34493447                        $this->assertArrayNotHasKey( 'author_ip', $data );
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r60197 r60251  
    877877
    878878                $all_data = $response->get_data();
     879
     880                $this->assertNotEmpty( $all_data );
     881
    879882                foreach ( $all_data as $post ) {
    880883                        $this->assertNotEquals( $draft_id, $post['id'] );
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r59880 r60251  
    18721872                $routes = rest_get_server()->get_routes( 'oembed/1.0' );
    18731873
     1874                $this->assertNotEmpty( $routes );
     1875
    18741876                foreach ( $routes as $route => $handlers ) {
    18751877                        $this->assertStringStartsWith( '/oembed/1.0', $route );
  • trunk/tests/phpunit/tests/rest-api/rest-users-controller.php

    r60141 r60251  
    308308
    309309                $rest_post_types = array_values( get_post_types( array( 'show_in_rest' => true ), 'names' ) );
     310
     311                $this->assertNotEmpty( $users );
    310312
    311313                foreach ( $users as $user ) {
    … …  
    33603362                        $this->assertSame( $user->roles, $data['roles'] );
    33613363                        $this->assertSame( get_user_locale( $user ), $data['locale'] );
    3362                 }
    3363 
    3364                 if ( 'edit' !== $context ) {
     3364                } else {
    33653365                        $this->assertArrayNotHasKey( 'roles', $data );
    33663366                        $this->assertArrayNotHasKey( 'capabilities', $data );
  • trunk/tests/phpunit/tests/shortcode.php

    r57597 r60251  
    694694                add_shortcode( $input, '' );
    695695                $actual = shortcode_exists( $input );
    696                 $this->assertSame( $expected, $actual );
    697696                if ( $actual ) {
    698697                        remove_shortcode( $input );
    699698                }
     699
     700                $this->assertSame( $expected, $actual );
    700701        }
    701702
  • trunk/tests/phpunit/tests/taxonomy.php

    r56642 r60251  
    2929
    3030        public function test_get_post_taxonomy() {
    31                 foreach ( get_object_taxonomies( 'post' ) as $taxonomy ) {
     31                $taxonomies = get_object_taxonomies( 'post' );
     32
     33                $this->assertNotEmpty( $taxonomies );
     34
     35                foreach ( $taxonomies as $taxonomy ) {
    3236                        $tax = get_taxonomy( $taxonomy );
    3337                        // Should return an object with the correct taxonomy object type.
    … …  
    111115
    112116        public function test_get_link_taxonomy() {
    113                 foreach ( get_object_taxonomies( 'link' ) as $taxonomy ) {
     117                $taxonomies = get_object_taxonomies( 'link' );
     118
     119                $this->assertNotEmpty( $taxonomies );
     120
     121                foreach ( $taxonomies as $taxonomy ) {
    114122                        $tax = get_taxonomy( $taxonomy );
    115123                        // Should return an object with the correct taxonomy object type.
  • trunk/tests/phpunit/tests/term/cache.php

    r59015 r60251  
    223223                update_term_cache( $terms );
    224224
     225                $this->assertNotEmpty( $terms );
     226
    225227                foreach ( $terms as $term ) {
    226228                        $this->assertSame( $p, $term->object_id );
  • trunk/tests/phpunit/tests/term/meta.php

    r56549 r60251  
    133133                remove_action( 'pre_get_posts', array( $this, 'set_cache_results' ) );
    134134
    135                 if ( have_posts() ) {
    136                         while ( have_posts() ) {
    137                                 the_post();
    138 
    139                                 // First request will hit the database.
    140                                 $num_queries = get_num_queries();
    141                                 $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
    142                                 ++$num_queries;
    143                                 $this->assertSame( $num_queries, get_num_queries() );
    144 
    145                                 // Second and third requests should be in cache.
    146                                 $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
    147                                 $this->assertSame( 'bar', get_term_meta( $terms[2], 'foo', true ) );
    148                                 $this->assertSame( $num_queries, get_num_queries() );
    149 
    150                                 // Querying a term not primed should result in a hit.
    151                                 ++$num_queries;
    152                                 $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) );
    153                                 $this->assertSame( $num_queries, get_num_queries() );
    154                         }
     135                $this->assertTrue( have_posts() );
     136
     137                while ( have_posts() ) {
     138                        the_post();
     139
     140                        // First request will hit the database.
     141                        $num_queries = get_num_queries();
     142                        $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
     143                        ++$num_queries;
     144                        $this->assertSame( $num_queries, get_num_queries() );
     145
     146                        // Second and third requests should be in cache.
     147                        $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
     148                        $this->assertSame( 'bar', get_term_meta( $terms[2], 'foo', true ) );
     149                        $this->assertSame( $num_queries, get_num_queries() );
     150
     151                        // Querying a term not primed should result in a hit.
     152                        ++$num_queries;
     153                        $this->assertSame( 'bar', get_term_meta( $orphan_term, 'foo', true ) );
     154                        $this->assertSame( $num_queries, get_num_queries() );
    155155                }
    156156        }
    … …  
    202202                );
    203203
    204                 if ( $q->have_posts() ) {
    205                         while ( $q->have_posts() ) {
    206                                 $q->the_post();
    207 
    208                                 // Requests will hit the database.
    209                                 $num_queries = get_num_queries();
    210                                 $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
    211                                 ++$num_queries;
    212                                 $this->assertSame( $num_queries, get_num_queries() );
    213 
    214                                 $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
    215                                 ++$num_queries;
    216                                 $this->assertSame( $num_queries, get_num_queries() );
    217                         }
     204                $this->assertTrue( $q->have_posts() );
     205
     206                while ( $q->have_posts() ) {
     207                        $q->the_post();
     208
     209                        // Requests will hit the database.
     210                        $num_queries = get_num_queries();
     211                        $this->assertSame( 'bar', get_term_meta( $terms[0], 'foo', true ) );
     212                        ++$num_queries;
     213                        $this->assertSame( $num_queries, get_num_queries() );
     214
     215                        $this->assertSame( 'bar', get_term_meta( $terms[1], 'foo', true ) );
     216                        ++$num_queries;
     217                        $this->assertSame( $num_queries, get_num_queries() );
    218218                }
    219219        }
  • trunk/tests/phpunit/tests/term/wpGenerateTagCloud.php

    r55562 r60251  
    157157                );
    158158
     159                $this->assertNotEmpty( $tags );
     160
    159161                foreach ( $tags as $tag ) {
    160162                        $this->assertStringContainsString( '>' . $tag->name . '<', $found );
    … …  
    187189                $this->assertMatchesRegularExpression( "|^<ul class='wp-tag-cloud' role='list'>|", $found );
    188190                $this->assertMatchesRegularExpression( "|</ul>\n|", $found );
     191
     192                $this->assertNotEmpty( $tags );
    189193
    190194                foreach ( $tags as $tag ) {
  • trunk/tests/phpunit/tests/term/wpGetObjectTerms.php

    r56421 r60251  
    111111                $terms = wp_get_object_terms( $post_id, $this->taxonomy );
    112112                remove_filter( 'wp_get_object_terms', array( $this, 'filter_get_object_terms' ) );
     113
     114                $this->assertNotEmpty( $terms );
     115
    113116                foreach ( $terms as $term ) {
    114117                        $this->assertIsObject( $term );
    … …  
    845848                        )
    846849                );
     850
     851                $this->assertNotEmpty( $found );
    847852
    848853                foreach ( $found as $f ) {
  • trunk/tests/phpunit/tests/term/wpTaxonomy.php

    r56548 r60251  
    77        public function test_instances() {
    88                global $wp_taxonomies;
     9
     10                $this->assertNotEmpty( $wp_taxonomies );
    911
    1012                foreach ( $wp_taxonomies as $taxonomy ) {
  • trunk/tests/phpunit/tests/theme.php

    r59823 r60251  
    9090        public function test_get_theme() {
    9191                $themes = get_themes();
     92
     93                $this->assertNotEmpty( $themes );
     94
    9295                foreach ( array_keys( $themes ) as $name ) {
    9396                        $theme = get_theme( $name );
    … …  
    101104        public function test_wp_get_theme() {
    102105                $themes = wp_get_themes();
     106
     107                $this->assertNotEmpty( $themes );
     108
    103109                foreach ( $themes as $theme ) {
    104110                        $this->assertInstanceOf( 'WP_Theme', $theme );
    … …  
    116122        public function test_get_themes_contents() {
    117123                $themes = get_themes();
     124
     125                $this->assertNotEmpty( $themes );
     126
    118127                // Generic tests that should hold true for any theme.
    119128                foreach ( $themes as $k => $theme ) {
    … …  
    362371                $themes = get_themes();
    363372
     373                $this->assertNotEmpty( $themes );
     374
    364375                // Switch to each theme in sequence.
    365376                // Do it twice to make sure we switch to the first theme, even if it's our starting theme.
  • trunk/tests/phpunit/tests/xmlrpc/wp/getComments.php

    r52010 r60251  
    2929                $results = $this->myxmlrpcserver->wp_getComments( array( 1, 'editor', 'editor', array() ) );
    3030                $this->assertNotIXRError( $results );
     31                $this->assertNotEmpty( $results );
    3132
    3233                foreach ( $results as $result ) {
    … …  
    5354                );
    5455                $this->assertNotIXRError( $results );
     56                $this->assertNotEmpty( $results );
    5557
    5658                foreach ( $results as $result ) {
  • trunk/tests/phpunit/tests/xmlrpc/wp/getPageList.php

    r52010 r60251  
    4242                $results = $this->myxmlrpcserver->wp_getPageList( array( 1, 'editor', 'editor' ) );
    4343                $this->assertNotIXRError( $results );
     44                $this->assertNotEmpty( $results );
    4445
    4546                foreach ( $results as $result ) {
  • trunk/tests/phpunit/tests/xmlrpc/wp/getPages.php

    r56547 r60251  
    4848                $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'administrator', 'administrator' ) );
    4949                $this->assertNotIXRError( $results );
     50                $this->assertNotEmpty( $results );
    5051
    5152                foreach ( $results as $result ) {
  • trunk/tests/phpunit/tests/xmlrpc/wp/getPosts.php

    r56547 r60251  
    101101                $results2 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter2 ) );
    102102                $this->assertNotIXRError( $results2 );
     103                $this->assertNotEmpty( $results2 );
     104
    103105                $last_comment_count = 100;
    104106                foreach ( $results2 as $post ) {
  • trunk/tests/phpunit/tests/xmlrpc/wp/getTerms.php

    r52010 r60251  
    4747                $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category' ) );
    4848                $this->assertNotIXRError( $results );
     49                $this->assertNotEmpty( $results );
    4950
    5051                foreach ( $results as $term ) {
  • trunk/tests/phpunit/tests/xmlrpc/wp/getUsers.php

    r52010 r60251  
    118118                $results = $this->myxmlrpcserver->wp_getUsers( array( 1, 'administrator', 'administrator', $filter ) );
    119119                $this->assertNotIXRError( $results );
     120                $this->assertNotEmpty( $results );
    120121
    121122                $last_email = '';
Note: See TracChangeset for help on using the changeset viewer.