Make WordPress Core

Changeset 51397


Ignore:
Timestamp:
07/10/2021 11:15:44 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use more appropriate assertions in various tests.

This replaces instances of assertTrue( isset( ... ) ) with assertArrayHasKey() to use native PHPUnit functionality.

Follow-up to [51335], [51337], [51367].

See #53363.

Location:
trunk/tests/phpunit
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/testcase-rest-post-type-controller.php

    r50283 r51397  
    4747            }
    4848        } else {
    49             $this->assertFalse( isset( $data['parent'] ) );
     49            $this->assertArrayNotHasKey( 'parent', $data );
    5050        }
    5151
     
    5454            $this->assertSame( $post->menu_order, $data['menu_order'] );
    5555        } else {
    56             $this->assertFalse( isset( $data['menu_order'] ) );
     56            $this->assertArrayNotHasKey( 'menu_order', $data );
    5757        }
    5858
     
    6262            $this->assertSame( $post->ping_status, $data['ping_status'] );
    6363        } else {
    64             $this->assertFalse( isset( $data['comment_status'] ) );
    65             $this->assertFalse( isset( $data['ping_status'] ) );
     64            $this->assertArrayNotHasKey( 'comment_status', $data );
     65            $this->assertArrayNotHasKey( 'ping_status', $data );
    6666        }
    6767
     
    8181            $this->assertSame( (int) get_post_thumbnail_id( $post->ID ), $data['featured_media'] );
    8282        } else {
    83             $this->assertFalse( isset( $data['featured_media'] ) );
     83            $this->assertArrayNotHasKey( 'featured_media', $data );
    8484        }
    8585
     
    9393            }
    9494        } else {
    95             $this->assertFalse( isset( $data['format'] ) );
     95            $this->assertArrayNotHasKey( 'format', $data );
    9696        }
    9797
     
    104104                $this->assertSame( $post->post_title, $data['title']['raw'] );
    105105            } else {
    106                 $this->assertFalse( isset( $data['title']['raw'] ) );
    107             }
    108         } else {
    109             $this->assertFalse( isset( $data['title'] ) );
     106                $this->assertArrayNotHasKey( 'raw', $data['title'] );
     107            }
     108        } else {
     109            $this->assertArrayNotHasKey( 'title', $data );
    110110        }
    111111
     
    119119                $this->assertSame( $post->post_content, $data['content']['raw'] );
    120120            } else {
    121                 $this->assertFalse( isset( $data['content']['raw'] ) );
    122             }
    123         } else {
    124             $this->assertFalse( isset( $data['content'] ) );
     121                $this->assertArrayNotHasKey( 'raw', $data['content'] );
     122            }
     123        } else {
     124            $this->assertArrayNotHasKey( 'content', $data );
    125125        }
    126126
     
    135135                $this->assertSame( $post->post_excerpt, $data['excerpt']['raw'] );
    136136            } else {
    137                 $this->assertFalse( isset( $data['excerpt']['raw'] ) );
    138             }
    139         } else {
    140             $this->assertFalse( isset( $data['excerpt'] ) );
     137                $this->assertArrayNotHasKey( 'raw', $data['excerpt'] );
     138            }
     139        } else {
     140            $this->assertArrayNotHasKey( 'excerpt', $data );
    141141        }
    142142
     
    150150        $taxonomies = wp_list_filter( get_object_taxonomies( $post->post_type, 'objects' ), array( 'show_in_rest' => true ) );
    151151        foreach ( $taxonomies as $taxonomy ) {
    152             $this->assertTrue( isset( $data[ $taxonomy->rest_base ] ) );
     152            $this->assertArrayHasKey( $taxonomy->rest_base, $data );
    153153            $terms = wp_get_object_terms( $post->ID, $taxonomy->name, array( 'fields' => 'ids' ) );
    154154            sort( $terms );
  • trunk/tests/phpunit/tests/actions.php

    r48937 r51397  
    424424        add_action( $tag, '__return_null', 11, 1 );
    425425
    426         $this->assertTrue( isset( $wp_filter[ $tag ][11] ) );
     426        $this->assertArrayHasKey( 11, $wp_filter[ $tag ] );
    427427        $this->assertArrayHasKey( '__return_null', $wp_filter[ $tag ][11] );
    428428
  • trunk/tests/phpunit/tests/admin/includesPlugin.php

    r51335 r51397  
    3131
    3232        foreach ( $default_headers as $name => $value ) {
    33             $this->assertTrue( isset( $data[ $name ] ) );
     33            $this->assertArrayHasKey( $name, $data );
    3434            $this->assertSame( $value, $data[ $name ] );
    3535        }
     
    553553
    554554        $result = validate_active_plugins();
    555         $this->assertTrue( isset( $result[ $plugin[0] ] ) );
     555        $this->assertArrayHasKey( $plugin[0], $result );
    556556    }
    557557
  • trunk/tests/phpunit/tests/adminbar.php

    r51331 r51397  
    703703        $nodes = $wp_admin_bar->get_nodes();
    704704        foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
    705             $this->assertFalse( isset( $nodes[ $id ] ), sprintf( 'Menu item %s must not display for a regular user.', $id ) );
     705            $this->assertArrayNotHasKey( $id, $nodes, sprintf( 'Menu item %s must not display for a regular user.', $id ) );
    706706        }
    707707    }
     
    720720        $nodes = $wp_admin_bar->get_nodes();
    721721        foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
    722             $this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %s must display for a super admin.', $id ) );
     722            $this->assertArrayHasKey( $id, $nodes, sprintf( 'Menu item %s must display for a super admin.', $id ) );
    723723        }
    724724    }
     
    746746        foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
    747747            if ( in_array( $cap, $network_user_caps, true ) ) {
    748                 $this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) );
     748                $this->assertArrayHasKey( $id, $nodes, sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) );
    749749            } else {
    750                 $this->assertFalse( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must not display for a user without the %2$s cap.', $id, $cap ) );
     750                $this->assertArrayNotHasKey( $id, $nodes, sprintf( 'Menu item %1$s must not display for a user without the %2$s cap.', $id, $cap ) );
    751751            }
    752752        }
  • trunk/tests/phpunit/tests/blocks/block-list.php

    r51367 r51397  
    5252
    5353        // Test "offsetExists".
    54         $this->assertTrue( isset( $blocks[0] ) );
     54        $this->assertArrayHasKey( 0, $blocks );
    5555
    5656        // Test "offsetGet".
     
    6464        // Test "offsetUnset".
    6565        unset( $blocks[0] );
    66         $this->assertFalse( isset( $blocks[0] ) );
     66        $this->assertArrayNotHasKey( 0, $blocks );
    6767    }
    6868
  • trunk/tests/phpunit/tests/dependencies.php

    r48937 r51397  
    101101        $this->assertFalse( $dep->query( 'one', 'queue' ) );
    102102        $this->assertTrue( $dep->query( 'two', 'queue' ) );
    103         $this->assertFalse( isset( $dep->args['one'] ) );
     103        $this->assertArrayNotHasKey( 'one', $dep->args );
    104104
    105105        $dep->dequeue( 'two' );
    106106        $this->assertFalse( $dep->query( 'one', 'queue' ) );
    107107        $this->assertFalse( $dep->query( 'two', 'queue' ) );
    108         $this->assertFalse( isset( $dep->args['two'] ) );
     108        $this->assertArrayNotHasKey( 'two', $dep->args );
    109109    }
    110110
  • trunk/tests/phpunit/tests/dependencies/jquery.php

    r50441 r51397  
    3535            $o = $scripts->query( $dep, 'registered' );
    3636            $this->assertInstanceOf( '_WP_Dependency', $object );
    37             $this->assertTrue( isset( $jquery_scripts[ $dep ] ) );
     37            $this->assertArrayHasKey( $dep, $jquery_scripts );
    3838            $this->assertSame( $jquery_scripts[ $dep ], $o->src );
    3939        }
  • trunk/tests/phpunit/tests/feed/rss2.php

    r51367 r51397  
    132132
    133133        // The channel should be free of attributes.
    134         $this->assertTrue( empty( $channel[0]['attributes'] ) );
     134        $this->assertArrayNotHasKey( 'attributes', $channel[0] );
    135135
    136136        // Verify the channel is present and contains a title child element.
  • trunk/tests/phpunit/tests/hooks/removeFilter.php

    r50342 r51397  
    1919        $hook->remove_filter( $tag, $callback, $priority );
    2020
    21         $this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
     21        $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    2222    }
    2323
     
    3333        $hook->remove_filter( $tag, $callback, $priority );
    3434
    35         $this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
     35        $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    3636    }
    3737
     
    4646        $hook->remove_filter( $tag, $callback, $priority );
    4747
    48         $this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
     48        $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    4949    }
    5050
     
    7777
    7878        $hook->remove_filter( $tag, $callback_one, $priority );
    79         $this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
     79        $this->assertArrayNotHasKey( $priority, $hook->callbacks );
    8080        $this->assertCount( 1, $hook->callbacks[ $priority + 1 ] );
    8181    }
  • trunk/tests/phpunit/tests/http/base.php

    r51331 r51397  
    256256        }
    257257
    258         $this->assertTrue( isset( $headers['test1'] ) && 'test' === $headers['test1'] );
    259         $this->assertTrue( isset( $headers['test2'] ) && '0' === $headers['test2'] );
     258        $this->assertArrayHasKey( 'test1', $headers );
     259        $this->assertSame( 'test', $headers['test1'] );
     260        $this->assertArrayHasKey( 'test2', $headers );
     261        $this->assertSame( '0', $headers['test2'] );
    260262        // cURL/HTTP Extension Note: Will never pass, cURL does not pass headers with an empty value.
    261263        // Should it be that empty headers with empty values are NOT sent?
    262         // $this->assertTrue( isset( $headers['test3'] ) && '' === $headers['test3'] );
     264        // $this->assertArrayHasKey( 'test3', $headers );
     265        // $this->assertSame( '', $headers['test3'] );
    263266    }
    264267
  • trunk/tests/phpunit/tests/http/http.php

    r50537 r51397  
    314314        foreach ( array_keys( $cookies ) as $cookie ) {
    315315            if ( 'foo' === $cookie ) {
    316                 $this->assertFalse( isset( $cookie_jar[ $cookie ] ) );
     316                $this->assertArrayNotHasKey( $cookie, $cookie_jar );
    317317            } else {
    318318                $this->assertInstanceOf( 'Requests_Cookie', $cookie_jar[ $cookie ] );
  • trunk/tests/phpunit/tests/image/functions.php

    r51331 r51397  
    648648
    649649        $metadata = wp_generate_attachment_metadata( $attachment_id, $test_file );
    650         $this->assertTrue( isset( $metadata['sizes']['test-size'] ), 'The `test-size` was not added to the metadata.' );
     650        $this->assertArrayHasKey( 'test-size', $metadata['sizes'], 'The `test-size` was not added to the metadata.' );
    651651        $this->assertSame( $metadata['sizes']['test-size'], $expected );
    652652
  • trunk/tests/phpunit/tests/image/intermediateSize.php

    r51331 r51397  
    6060        $this->assertSame( 'image/jpeg', $image['mime-type'] );
    6161
    62         $this->assertFalse( isset( $image['path'] ) );
     62        $this->assertArrayNotHasKey( 'path', $image );
    6363    }
    6464
  • trunk/tests/phpunit/tests/includes/helpers.php

    r48996 r51397  
    228228        $stati = get_post_stati();
    229229
    230         $this->assertFalse( isset( $stati['foo'] ) );
     230        $this->assertArrayNotHasKey( 'foo', $stati );
    231231    }
    232232
  • trunk/tests/phpunit/tests/kses.php

    r50987 r51397  
    508508
    509509        $tags = wp_kses_allowed_html();
    510         $this->assertFalse( isset( $tags['a']['rel'] ) );
     510        $this->assertArrayNotHasKey( 'rel', $tags['a'] );
    511511
    512512        $this->assertSame( array(), wp_kses_allowed_html( 'strip' ) );
  • trunk/tests/phpunit/tests/media.php

    r51331 r51397  
    447447        $prepped = wp_prepare_attachment_for_js( get_post( $id ) );
    448448
    449         $this->assertTrue( isset( $prepped['sizes'] ) );
     449        $this->assertArrayHasKey( 'sizes', $prepped );
    450450    }
    451451
  • trunk/tests/phpunit/tests/meta/query.php

    r49554 r51397  
    147147        $query->parse_query_vars( $qv );
    148148
    149         $this->assertTrue( ! isset( $query->queries[0]['value'] ) );
     149        $this->assertArrayNotHasKey( 'value', $query->queries[0] );
    150150    }
    151151
     
    164164        $query->parse_query_vars( $qv );
    165165
    166         $this->assertTrue( ! isset( $query->queries[0]['value'] ) );
     166        $this->assertArrayNotHasKey( 'value', $query->queries[0] );
    167167    }
    168168
  • trunk/tests/phpunit/tests/oembed/filterResult.php

    r49117 r51397  
    2020        preg_match( '|src=".*#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches );
    2121
    22         $this->assertTrue( isset( $matches[1] ) );
    23         $this->assertTrue( isset( $matches[2] ) );
     22        $this->assertArrayHasKey( 1, $matches );
     23        $this->assertArrayHasKey( 2, $matches );
    2424        $this->assertSame( $matches[1], $matches[2] );
    2525    }
     
    6464        preg_match( '|src="https://wordpress.org#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches );
    6565
    66         $this->assertTrue( isset( $matches[1] ) );
    67         $this->assertTrue( isset( $matches[2] ) );
     66        $this->assertArrayHasKey( 1, $matches );
     67        $this->assertArrayHasKey( 2, $matches );
    6868        $this->assertSame( $matches[1], $matches[2] );
    6969    }
  • trunk/tests/phpunit/tests/option/networkOption.php

    r48937 r51397  
    6262        $options = wp_load_alloptions();
    6363
    64         $this->assertFalse( isset( $options[ $key ] ) );
     64        $this->assertArrayNotHasKey( $key, $options );
    6565    }
    6666
     
    7676        $options = wp_load_alloptions();
    7777
    78         $this->assertFalse( isset( $options[ $key ] ) );
     78        $this->assertArrayNotHasKey( $key, $options );
    7979    }
    8080
  • trunk/tests/phpunit/tests/option/siteTransient.php

    r48937 r51397  
    5757        $options = wp_load_alloptions();
    5858
    59         $this->assertFalse( isset( $options[ '_site_transient_' . $key ] ) );
     59        $this->assertArrayNotHasKey( '_site_transient_' . $key, $options );
    6060    }
    6161}
  • trunk/tests/phpunit/tests/post.php

    r51367 r51397  
    892892
    893893        $counts = wp_count_posts();
    894         $this->assertTrue( isset( $counts->test ) );
     894        $this->assertObjectHasAttribute( 'test', $counts );
    895895        $this->assertSame( 0, $counts->test );
    896896    }
  • trunk/tests/phpunit/tests/post/objects.php

    r51367 r51397  
    3636        $post = get_post( $id, ARRAY_N );
    3737        $this->assertIsArray( $post );
    38         $this->assertFalse( isset( $post['post_type'] ) );
     38        $this->assertArrayNotHasKey( 'post_type', $post );
    3939        $this->assertTrue( in_array( 'post', $post, true ) );
    4040
  • trunk/tests/phpunit/tests/post/types.php

    r51367 r51397  
    395395        $this->assertTrue( unregister_post_type( 'foo' ) );
    396396
    397         $this->assertFalse( isset( $post_type_meta_caps['read_bar'] ) );
    398         $this->assertFalse( isset( $post_type_meta_caps['delete_bar'] ) );
    399         $this->assertFalse( isset( $post_type_meta_caps['edit_bar'] ) );
     397        $this->assertArrayNotHasKey( 'read_bar', $post_type_meta_caps );
     398        $this->assertArrayNotHasKey( 'delete_bar', $post_type_meta_caps );
     399        $this->assertArrayNotHasKey( 'edit_bar', $post_type_meta_caps );
    400400    }
    401401
     
    423423        );
    424424        $this->assertTrue( unregister_post_type( 'foo' ) );
    425         $this->assertFalse( isset( $_wp_post_type_features['foo'] ) );
     425        $this->assertArrayNotHasKey( 'foo', $_wp_post_type_features );
    426426    }
    427427
     
    505505        $this->assertTrue( unregister_post_type( 'foo' ) );
    506506
    507         $this->assertFalse( isset( $wp_post_types['foo'] ) );
     507        $this->assertArrayNotHasKey( 'foo', $wp_post_types );
    508508        $this->assertNull( get_post_type_object( 'foo' ) );
    509509    }
  • trunk/tests/phpunit/tests/rest-api.php

    r50156 r51397  
    238238        );
    239239        $endpoints = $GLOBALS['wp_rest_server']->get_routes();
    240         $this->assertFalse( isset( $endpoints['/test-empty-namespace'] ) );
     240        $this->assertArrayNotHasKey( '/test-empty-namespace', $endpoints );
    241241    }
    242242
     
    258258        );
    259259        $endpoints = $GLOBALS['wp_rest_server']->get_routes();
    260         $this->assertFalse( isset( $endpoints['/test-empty-route'] ) );
     260        $this->assertArrayNotHasKey( '/test-empty-route', $endpoints );
    261261    }
    262262
     
    952952
    953953        $this->assertSame( array_keys( $preload_data ), array( '/wp/v2/types', 'OPTIONS' ) );
    954         $this->assertTrue( isset( $preload_data['OPTIONS']['/wp/v2/media'] ) );
     954        $this->assertArrayHasKey( '/wp/v2/media', $preload_data['OPTIONS'] );
    955955
    956956        $GLOBALS['wp_rest_server'] = $rest_server;
  • trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php

    r51367 r51397  
    692692
    693693        $this->assertIsArray( $data['media_details']['sizes'], 'Could not retrieve the sizes data.' );
    694         $this->assertFalse( isset( $data['media_details']['sizes']['rest-api-test']['source_url'] ) );
     694        $this->assertArrayNotHasKey( 'source_url', $data['media_details']['sizes']['rest-api-test'] );
    695695    }
    696696
     
    16871687            $this->assertSame( $attachment->post_content, $data['description']['raw'] );
    16881688        } else {
    1689             $this->assertFalse( isset( $data['caption']['raw'] ) );
    1690             $this->assertFalse( isset( $data['description']['raw'] ) );
     1689            $this->assertArrayNotHasKey( 'raw', $data['caption'] );
     1690            $this->assertArrayNotHasKey( 'raw', $data['description'] );
    16911691        }
    1692         $this->assertTrue( isset( $data['media_details'] ) );
     1692        $this->assertArrayHasKey( 'media_details', $data );
    16931693
    16941694        if ( $attachment->post_parent ) {
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r51367 r51397  
    748748
    749749        $meta = (array) $data['meta'];
    750         $this->assertFalse( isset( $meta['test_tag_meta'] ) );
     750        $this->assertArrayNotHasKey( 'test_tag_meta', $meta );
    751751    }
    752752
     
    943943        $this->assertSame( 'just meta', $data['meta']['test_single'] );
    944944        $this->assertSame( 'category-specific meta', $data['meta']['test_cat_single'] );
    945         $this->assertFalse( isset( $data['meta']['test_tag_meta'] ) );
     945        $this->assertArrayNotHasKey( 'test_tag_meta', $data['meta'] );
    946946    }
    947947
     
    12101210            $this->assertSame( $term->parent, $data['parent'] );
    12111211        } else {
    1212             $this->assertFalse( isset( $term->parent ) );
     1212            $this->assertObjectNotHasProperty( 'parent', $term );
    12131213        }
    12141214
  • trunk/tests/phpunit/tests/rest-api/rest-controller.php

    r50450 r51397  
    250250
    251251        $this->assertSame( 'A pretty string.', $args['somestring']['description'] );
    252         $this->assertFalse( isset( $args['someinteger']['description'] ) );
     252        $this->assertArrayNotHasKey( 'description', $args['someinteger'] );
    253253    }
    254254
  • trunk/tests/phpunit/tests/rest-api/rest-post-types-controller.php

    r51367 r51397  
    4444        $this->assertSame( $post_types['page']->name, $data['page']['slug'] );
    4545        $this->check_post_type_obj( 'view', $post_types['page'], $data['page'], $data['page']['_links'] );
    46         $this->assertFalse( isset( $data['revision'] ) );
     46        $this->assertArrayNotHasKey( 'revision', $data );
    4747    }
    4848
     
    219219            $this->assertSame( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] );
    220220        } else {
    221             $this->assertFalse( isset( $data['capabilities'] ) );
    222             $this->assertFalse( isset( $data['viewable'] ) );
    223             $this->assertFalse( isset( $data['labels'] ) );
    224             $this->assertFalse( isset( $data['supports'] ) );
     221            $this->assertArrayNotHasKey( 'capabilities', $data );
     222            $this->assertArrayNotHasKey( 'viewable', $data );
     223            $this->assertArrayNotHasKey( 'labels', $data );
     224            $this->assertArrayNotHasKey( 'supports', $data );
    225225        }
    226226    }
  • trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r51368 r51397  
    17781778        $this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
    17791779        $this->assertSame( 0, $links['version-history'][0]['attributes']['count'] );
    1780         $this->assertFalse( isset( $links['predecessor-version'] ) );
     1780        $this->assertArrayNotHasKey( 'predecessor-version', $links );
    17811781
    17821782        $attachments_url = rest_url( '/wp/v2/media' );
     
    18341834        $response = rest_get_server()->dispatch( $request );
    18351835        $links    = $response->get_links();
    1836         $this->assertFalse( isset( $links['author'] ) );
     1836        $this->assertArrayNotHasKey( 'author', $links );
    18371837        wp_update_post(
    18381838            array(
     
    20312031        $response = rest_get_server()->dispatch( $request );
    20322032        $data     = $response->get_data();
    2033         $this->assertFalse( isset( $data['content']['block_version'] ) );
     2033        $this->assertArrayNotHasKey( 'block_version', $data['content'] );
    20342034    }
    20352035
     
    41584158        create_initial_rest_routes();
    41594159        $routes = rest_get_server()->get_routes();
    4160         $this->assertFalse( isset( $routes['/wp/v2/invalid-controller'] ) );
     4160        $this->assertArrayNotHasKey( '/wp/v2/invalid-controller', $routes );
    41614161        _unregister_post_type( 'invalid-controller' );
    41624162
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r51331 r51397  
    11191119            }
    11201120
    1121             $this->assertTrue( isset( $headers[ $header ] ), sprintf( 'Header %s is not present in the response.', $header ) );
     1121            $this->assertArrayHasKey( $header, $headers, sprintf( 'Header %s is not present in the response.', $header ) );
    11221122            $this->assertSame( $value, $headers[ $header ] );
    11231123        }
    11241124
    11251125        // Last-Modified should be unset as per #WP23021.
    1126         $this->assertFalse( isset( $headers['Last-Modified'] ), 'Last-Modified should not be sent.' );
     1126        $this->assertArrayNotHasKey( 'Last-Modified', $headers, 'Last-Modified should not be sent.' );
    11271127    }
    11281128
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r51367 r51397  
    701701
    702702        $meta = (array) $data['meta'];
    703         $this->assertFalse( isset( $meta['test_cat_meta'] ) );
     703        $this->assertArrayNotHasKey( 'test_cat_meta', $meta );
    704704    }
    705705
     
    875875        $this->assertSame( 'just meta', $data['meta']['test_single'] );
    876876        $this->assertSame( 'tag-specific meta', $data['meta']['test_tag_single'] );
    877         $this->assertFalse( isset( $data['meta']['test_cat_meta'] ) );
     877        $this->assertArrayNotHasKey( 'test_cat_meta', $data['meta'] );
    878878    }
    879879
     
    12431243        $properties = $data['schema']['properties'];
    12441244        $this->assertArrayHasKey( 'id', $properties );
    1245         $this->assertFalse( isset( $properties['parent'] ) );
     1245        $this->assertArrayNotHasKey( 'parent', $properties );
    12461246    }
    12471247
     
    14281428            $this->assertSame( $term->parent, $data['parent'] );
    14291429        } else {
    1430             $this->assertFalse( isset( $data['parent'] ) );
     1430            $this->assertArrayNotHasKey( 'parent', $data );
    14311431        }
    14321432        $expected_links = array(
  • trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php

    r51367 r51397  
    267267            $this->assertSame( $tax_obj->show_ui, $data['visibility']['show_ui'] );
    268268        } else {
    269             $this->assertFalse( isset( $data['capabilities'] ) );
    270             $this->assertFalse( isset( $data['labels'] ) );
    271             $this->assertFalse( isset( $data['show_cloud'] ) );
    272             $this->assertFalse( isset( $data['visibility'] ) );
     269            $this->assertArrayNotHasKey( 'capabilities', $data );
     270            $this->assertArrayNotHasKey( 'labels', $data );
     271            $this->assertArrayNotHasKey( 'show_cloud', $data );
     272            $this->assertArrayNotHasKey( 'visibility', $data );
    273273        }
    274274    }
  • trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php

    r51367 r51397  
    10301030        $response = self::perform_active_theme_request();
    10311031        $result   = $response->get_data();
    1032         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
    1033         $this->assertTrue( isset( $result[0]['theme_supports']['formats'] ) );
     1032        $this->assertArrayHasKey( 'theme_supports', $result[0] );
     1033        $this->assertArrayHasKey( 'formats', $result[0]['theme_supports'] );
    10341034        $this->assertSame( array( 'standard' ), $result[0]['theme_supports']['formats'] );
    10351035    }
     
    10441044        $response = self::perform_active_theme_request();
    10451045        $result   = $response->get_data();
    1046         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
    1047         $this->assertTrue( isset( $result[0]['theme_supports']['formats'] ) );
     1046        $this->assertArrayHasKey( 'theme_supports', $result[0] );
     1047        $this->assertArrayHasKey( 'formats', $result[0]['theme_supports'] );
    10481048        $this->assertSame( array( 'standard', 'aside', 'video' ), $result[0]['theme_supports']['formats'] );
    10491049    }
     
    10591059
    10601060        $result = $response->get_data();
    1061         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
    1062         $this->assertTrue( isset( $result[0]['theme_supports']['responsive-embeds'] ) );
     1061        $this->assertArrayHasKey( 'theme_supports', $result[0] );
     1062        $this->assertArrayHasKey( 'responsive-embeds', $result[0]['theme_supports'] );
    10631063        $this->assertFalse( $result[0]['theme_supports']['responsive-embeds'] );
    10641064    }
     
    10741074        $response = self::perform_active_theme_request();
    10751075        $result   = $response->get_data();
    1076         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     1076        $this->assertArrayHasKey( 'theme_supports', $result[0] );
    10771077        $this->assertTrue( $result[0]['theme_supports']['responsive-embeds'] );
    10781078    }
     
    10881088
    10891089        $result = $response->get_data();
    1090         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
    1091         $this->assertTrue( isset( $result[0]['theme_supports']['post-thumbnails'] ) );
     1090        $this->assertArrayHasKey( 'theme_supports', $result[0] );
     1091        $this->assertArrayHasKey( 'post-thumbnails', $result[0]['theme_supports'] );
    10921092        $this->assertFalse( $result[0]['theme_supports']['post-thumbnails'] );
    10931093    }
     
    11031103        $response = self::perform_active_theme_request();
    11041104        $result   = $response->get_data();
    1105         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     1105        $this->assertArrayHasKey( 'theme_supports', $result[0] );
    11061106        $this->assertTrue( $result[0]['theme_supports']['post-thumbnails'] );
    11071107    }
     
    11171117        $response = self::perform_active_theme_request();
    11181118        $result   = $response->get_data();
    1119         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     1119        $this->assertArrayHasKey( 'theme_supports', $result[0] );
    11201120        $this->assertSame( array( 'post' ), $result[0]['theme_supports']['post-thumbnails'] );
    11211121    }
     
    11431143        $response = self::perform_active_theme_request();
    11441144        $result   = $response->get_data();
    1145         $this->assertTrue( isset( $result[0]['theme_supports'] ) );
     1145        $this->assertArrayHasKey( 'theme_supports', $result[0] );
    11461146        $this->assertSame( array( 'a', 'b', 'c' ), $result[0]['theme_supports']['test-feature'] );
    11471147    }
  • trunk/tests/phpunit/tests/rewrite/permastructs.php

    r51331 r51397  
    3939
    4040        remove_permastruct( 'foo' );
    41         $this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) );
     41        $this->assertArrayNotHasKey( 'foo', $wp_rewrite->extra_permastructs );
    4242    }
    4343}
  • trunk/tests/phpunit/tests/sitemaps/sitemaps-posts.php

    r48937 r51397  
    5959        $sitemap_entry = array_shift( $url_list );
    6060
    61         $this->assertTrue( isset( $sitemap_entry['lastmod'] ) );
     61        $this->assertArrayHasKey( 'lastmod', $sitemap_entry );
    6262    }
    6363
  • trunk/tests/phpunit/tests/taxonomy.php

    r51367 r51397  
    843843        $this->assertIsArray( $wp_rewrite->extra_permastructs['foo'] );
    844844        $this->assertTrue( unregister_taxonomy( 'foo' ) );
    845         $this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) );
     845        $this->assertArrayNotHasKey( 'foo', $wp_rewrite->extra_permastructs );
    846846    }
    847847
     
    879879        $this->assertTrue( unregister_taxonomy( 'foo' ) );
    880880
    881         $this->assertFalse( isset( $wp_taxonomies['foo'] ) );
     881        $this->assertArrayNotHasKey( 'foo', $wp_taxonomies );
    882882        $this->assertFalse( get_taxonomy( 'foo' ) );
    883883    }
  • trunk/tests/phpunit/tests/term/getTerm.php

    r51331 r51397  
    105105        $term = get_term( $t, 'wptests_tax', ARRAY_A );
    106106        $this->assertIsArray( $term );
    107         $this->assertTrue( isset( $term['term_id'] ) );
     107        $this->assertArrayHasKey( 'term_id', $term );
    108108    }
    109109
     
    112112        $term = get_term( $t, 'wptests_tax', ARRAY_N );
    113113        $this->assertIsArray( $term );
    114         $this->assertFalse( isset( $term['term_id'] ) );
     114        $this->assertArrayNotHasKey( 'term_id', $term );
    115115        foreach ( $term as $k => $v ) {
    116116            $this->assertIsInt( $k );
  • trunk/tests/phpunit/tests/term/wpGetObjectTerms.php

    r51367 r51397  
    839839
    840840        $term = get_term( $t );
    841         $this->assertFalse( isset( $term->object_id ) );
     841        $this->assertObjectNotHasAttribute( 'object_id', $term );
    842842    }
    843843
  • trunk/tests/phpunit/tests/theme.php

    r51335 r51397  
    132132            );
    133133            foreach ( $default_headers as $name => $value ) {
    134                 $this->assertTrue( isset( $theme[ $name ] ) );
     134                $this->assertArrayHasKey( $name, $theme );
    135135            }
    136136
  • trunk/tests/phpunit/tests/user.php

    r51367 r51397  
    167167        // So we'll just check to make sure our values are included somewhere.
    168168        foreach ( $vals as $k => $v ) {
    169             $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
     169            $this->assertArrayHasKey( $k, $out );
     170            $this->assertSame( $v, $out[ $k ][0] );
    170171        }
    171172        // Delete one key and check again.
     
    177178        foreach ( $vals as $k => $v ) {
    178179            if ( $k === $key_to_delete ) {
    179                 $this->assertFalse( isset( $out[ $k ] ) );
     180                $this->assertArrayNotHasKey( $k, $out );
    180181            } else {
    181                 $this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
     182                $this->assertArrayHasKey( $k, $out );
     183                $this->assertSame( $v, $out[ $k ][0] );
    182184            }
    183185        }
  • trunk/tests/phpunit/tests/user/capabilities.php

    r50491 r51397  
    16091609
    16101610        $author->add_cap( 'foo', false );
    1611         $this->assertTrue( isset( $author->caps['foo'] ) );
     1611        $this->assertArrayHasKey( 'foo', $author->caps );
    16121612        $this->assertFalse( user_can( $author->ID, 'foo' ) );
    16131613
    16141614        $author->remove_cap( 'foo' );
    1615         $this->assertFalse( isset( $author->caps['foo'] ) );
     1615        $this->assertArrayNotHasKey( 'foo', $author->caps );
    16161616        $this->assertFalse( user_can( $author->ID, 'foo' ) );
    16171617    }
     
    22382238        $wp_roles->for_site( $site_id );
    22392239
    2240         $this->assertTrue( isset( $wp_roles->role_objects[ $role_name ] ) );
     2240        $this->assertArrayHasKey( $role_name, $wp_roles->role_objects );
    22412241    }
    22422242
  • trunk/tests/phpunit/tests/user/multisite.php

    r51331 r51397  
    7373            foreach ( $blogs_of_user as $blog_id => $blog ) {
    7474                $this->assertSame( $blog_id, $blog->userblog_id );
    75                 $this->assertTrue( isset( $blog->userblog_id ) );
    76                 $this->assertTrue( isset( $blog->blogname ) );
    77                 $this->assertTrue( isset( $blog->domain ) );
    78                 $this->assertTrue( isset( $blog->path ) );
    79                 $this->assertTrue( isset( $blog->site_id ) );
    80                 $this->assertTrue( isset( $blog->siteurl ) );
    81                 $this->assertTrue( isset( $blog->archived ) );
    82                 $this->assertTrue( isset( $blog->spam ) );
    83                 $this->assertTrue( isset( $blog->deleted ) );
     75                $this->assertObjectHasAttribute( 'userblog_id', $blog );
     76                $this->assertObjectHasAttribute( 'blogname', $blog );
     77                $this->assertObjectHasAttribute( 'domain', $blog );
     78                $this->assertObjectHasAttribute( 'path', $blog );
     79                $this->assertObjectHasAttribute( 'site_id', $blog );
     80                $this->assertObjectHasAttribute( 'siteurl', $blog );
     81                $this->assertObjectHasAttribute( 'archived', $blog );
     82                $this->assertObjectHasAttribute( 'spam', $blog );
     83                $this->assertObjectHasAttribute( 'deleted', $blog );
    8484            }
    8585
  • trunk/tests/phpunit/tests/widgets.php

    r51367 r51397  
    135135        register_sidebars( 1, array( 'id' => 'wp-unit-test' ) );
    136136
    137         $this->assertTrue( isset( $wp_registered_sidebars['wp-unit-test'] ) );
     137        $this->assertArrayHasKey( 'wp-unit-test', $wp_registered_sidebars );
    138138
    139139    }
Note: See TracChangeset for help on using the changeset viewer.