mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@51397 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -46,14 +46,14 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
$this->assertEmpty( $data['parent'] );
|
||||
}
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['parent'] ) );
|
||||
$this->assertArrayNotHasKey( 'parent', $data );
|
||||
}
|
||||
|
||||
// Page attributes.
|
||||
if ( $post_type_obj->hierarchical && post_type_supports( $post->post_type, 'page-attributes' ) ) {
|
||||
$this->assertSame( $post->menu_order, $data['menu_order'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['menu_order'] ) );
|
||||
$this->assertArrayNotHasKey( 'menu_order', $data );
|
||||
}
|
||||
|
||||
// Comments.
|
||||
@@ -61,8 +61,8 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
$this->assertSame( $post->comment_status, $data['comment_status'] );
|
||||
$this->assertSame( $post->ping_status, $data['ping_status'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['comment_status'] ) );
|
||||
$this->assertFalse( isset( $data['ping_status'] ) );
|
||||
$this->assertArrayNotHasKey( 'comment_status', $data );
|
||||
$this->assertArrayNotHasKey( 'ping_status', $data );
|
||||
}
|
||||
|
||||
if ( 'post' === $post->post_type ) {
|
||||
@@ -80,7 +80,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
if ( post_type_supports( $post->post_type, 'thumbnail' ) ) {
|
||||
$this->assertSame( (int) get_post_thumbnail_id( $post->ID ), $data['featured_media'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['featured_media'] ) );
|
||||
$this->assertArrayNotHasKey( 'featured_media', $data );
|
||||
}
|
||||
|
||||
// Check post format.
|
||||
@@ -92,7 +92,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
$this->assertSame( get_post_format( $post->ID ), $data['format'] );
|
||||
}
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['format'] ) );
|
||||
$this->assertArrayNotHasKey( 'format', $data );
|
||||
}
|
||||
|
||||
// Check filtered values.
|
||||
@@ -103,10 +103,10 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
if ( 'edit' === $context ) {
|
||||
$this->assertSame( $post->post_title, $data['title']['raw'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['title']['raw'] ) );
|
||||
$this->assertArrayNotHasKey( 'raw', $data['title'] );
|
||||
}
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['title'] ) );
|
||||
$this->assertArrayNotHasKey( 'title', $data );
|
||||
}
|
||||
|
||||
if ( post_type_supports( $post->post_type, 'editor' ) ) {
|
||||
@@ -118,10 +118,10 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
if ( 'edit' === $context ) {
|
||||
$this->assertSame( $post->post_content, $data['content']['raw'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['content']['raw'] ) );
|
||||
$this->assertArrayNotHasKey( 'raw', $data['content'] );
|
||||
}
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['content'] ) );
|
||||
$this->assertArrayNotHasKey( 'content', $data );
|
||||
}
|
||||
|
||||
if ( post_type_supports( $post->post_type, 'excerpt' ) ) {
|
||||
@@ -134,10 +134,10 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
if ( 'edit' === $context ) {
|
||||
$this->assertSame( $post->post_excerpt, $data['excerpt']['raw'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['excerpt']['raw'] ) );
|
||||
$this->assertArrayNotHasKey( 'raw', $data['excerpt'] );
|
||||
}
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['excerpt'] ) );
|
||||
$this->assertArrayNotHasKey( 'excerpt', $data );
|
||||
}
|
||||
|
||||
$this->assertSame( $post->post_status, $data['status'] );
|
||||
@@ -149,7 +149,7 @@ abstract class WP_Test_REST_Post_Type_Controller_Testcase extends WP_Test_REST_C
|
||||
|
||||
$taxonomies = wp_list_filter( get_object_taxonomies( $post->post_type, 'objects' ), array( 'show_in_rest' => true ) );
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$this->assertTrue( isset( $data[ $taxonomy->rest_base ] ) );
|
||||
$this->assertArrayHasKey( $taxonomy->rest_base, $data );
|
||||
$terms = wp_get_object_terms( $post->ID, $taxonomy->name, array( 'fields' => 'ids' ) );
|
||||
sort( $terms );
|
||||
sort( $data[ $taxonomy->rest_base ] );
|
||||
|
||||
@@ -423,7 +423,7 @@ class Tests_Actions extends WP_UnitTestCase {
|
||||
|
||||
add_action( $tag, '__return_null', 11, 1 );
|
||||
|
||||
$this->assertTrue( isset( $wp_filter[ $tag ][11] ) );
|
||||
$this->assertArrayHasKey( 11, $wp_filter[ $tag ] );
|
||||
$this->assertArrayHasKey( '__return_null', $wp_filter[ $tag ][11] );
|
||||
|
||||
unset( $wp_filter[ $tag ][11] );
|
||||
|
||||
@@ -30,7 +30,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
$this->assertIsArray( $data );
|
||||
|
||||
foreach ( $default_headers as $name => $value ) {
|
||||
$this->assertTrue( isset( $data[ $name ] ) );
|
||||
$this->assertArrayHasKey( $name, $data );
|
||||
$this->assertSame( $value, $data[ $name ] );
|
||||
}
|
||||
}
|
||||
@@ -552,7 +552,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
unlink( $plugin[1] );
|
||||
|
||||
$result = validate_active_plugins();
|
||||
$this->assertTrue( isset( $result[ $plugin[0] ] ) );
|
||||
$this->assertArrayHasKey( $plugin[0], $result );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -702,7 +702,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
|
||||
$nodes = $wp_admin_bar->get_nodes();
|
||||
foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
|
||||
$this->assertFalse( isset( $nodes[ $id ] ), sprintf( 'Menu item %s must not display for a regular user.', $id ) );
|
||||
$this->assertArrayNotHasKey( $id, $nodes, sprintf( 'Menu item %s must not display for a regular user.', $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
|
||||
$nodes = $wp_admin_bar->get_nodes();
|
||||
foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
|
||||
$this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %s must display for a super admin.', $id ) );
|
||||
$this->assertArrayHasKey( $id, $nodes, sprintf( 'Menu item %s must display for a super admin.', $id ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -745,9 +745,9 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
$nodes = $wp_admin_bar->get_nodes();
|
||||
foreach ( $this->get_my_sites_network_menu_items() as $id => $cap ) {
|
||||
if ( in_array( $cap, $network_user_caps, true ) ) {
|
||||
$this->assertTrue( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) );
|
||||
$this->assertArrayHasKey( $id, $nodes, sprintf( 'Menu item %1$s must display for a user with the %2$s cap.', $id, $cap ) );
|
||||
} else {
|
||||
$this->assertFalse( isset( $nodes[ $id ] ), sprintf( 'Menu item %1$s must not display for a user without the %2$s cap.', $id, $cap ) );
|
||||
$this->assertArrayNotHasKey( $id, $nodes, sprintf( 'Menu item %1$s must not display for a user without the %2$s cap.', $id, $cap ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class WP_Block_List_Test extends WP_UnitTestCase {
|
||||
$blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry );
|
||||
|
||||
// Test "offsetExists".
|
||||
$this->assertTrue( isset( $blocks[0] ) );
|
||||
$this->assertArrayHasKey( 0, $blocks );
|
||||
|
||||
// Test "offsetGet".
|
||||
$this->assertSame( 'core/example', $blocks[0]->name );
|
||||
@@ -63,7 +63,7 @@ class WP_Block_List_Test extends WP_UnitTestCase {
|
||||
|
||||
// Test "offsetUnset".
|
||||
unset( $blocks[0] );
|
||||
$this->assertFalse( isset( $blocks[0] ) );
|
||||
$this->assertArrayNotHasKey( 0, $blocks );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -100,12 +100,12 @@ class Tests_Dependencies extends WP_UnitTestCase {
|
||||
$dep->dequeue( 'one' );
|
||||
$this->assertFalse( $dep->query( 'one', 'queue' ) );
|
||||
$this->assertTrue( $dep->query( 'two', 'queue' ) );
|
||||
$this->assertFalse( isset( $dep->args['one'] ) );
|
||||
$this->assertArrayNotHasKey( 'one', $dep->args );
|
||||
|
||||
$dep->dequeue( 'two' );
|
||||
$this->assertFalse( $dep->query( 'one', 'queue' ) );
|
||||
$this->assertFalse( $dep->query( 'two', 'queue' ) );
|
||||
$this->assertFalse( isset( $dep->args['two'] ) );
|
||||
$this->assertArrayNotHasKey( 'two', $dep->args );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ class Tests_Dependencies_jQuery extends WP_UnitTestCase {
|
||||
foreach ( $object->deps as $dep ) {
|
||||
$o = $scripts->query( $dep, 'registered' );
|
||||
$this->assertInstanceOf( '_WP_Dependency', $object );
|
||||
$this->assertTrue( isset( $jquery_scripts[ $dep ] ) );
|
||||
$this->assertArrayHasKey( $dep, $jquery_scripts );
|
||||
$this->assertSame( $jquery_scripts[ $dep ], $o->src );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase {
|
||||
$channel = xml_find( $xml, 'rss', 'channel' );
|
||||
|
||||
// The channel should be free of attributes.
|
||||
$this->assertTrue( empty( $channel[0]['attributes'] ) );
|
||||
$this->assertArrayNotHasKey( 'attributes', $channel[0] );
|
||||
|
||||
// Verify the channel is present and contains a title child element.
|
||||
$title = xml_find( $xml, 'rss', 'channel', 'title' );
|
||||
|
||||
@@ -18,7 +18,7 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase {
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->remove_filter( $tag, $callback, $priority );
|
||||
|
||||
$this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
|
||||
$this->assertArrayNotHasKey( $priority, $hook->callbacks );
|
||||
}
|
||||
|
||||
public function test_remove_filter_with_object() {
|
||||
@@ -32,7 +32,7 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase {
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->remove_filter( $tag, $callback, $priority );
|
||||
|
||||
$this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
|
||||
$this->assertArrayNotHasKey( $priority, $hook->callbacks );
|
||||
}
|
||||
|
||||
public function test_remove_filter_with_static_method() {
|
||||
@@ -45,7 +45,7 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase {
|
||||
$hook->add_filter( $tag, $callback, $priority, $accepted_args );
|
||||
$hook->remove_filter( $tag, $callback, $priority );
|
||||
|
||||
$this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
|
||||
$this->assertArrayNotHasKey( $priority, $hook->callbacks );
|
||||
}
|
||||
|
||||
public function test_remove_filters_with_another_at_same_priority() {
|
||||
@@ -76,7 +76,7 @@ class Tests_Hooks_RemoveFilter extends WP_UnitTestCase {
|
||||
$hook->add_filter( $tag, $callback_two, $priority + 1, $accepted_args );
|
||||
|
||||
$hook->remove_filter( $tag, $callback_one, $priority );
|
||||
$this->assertFalse( isset( $hook->callbacks[ $priority ] ) );
|
||||
$this->assertArrayNotHasKey( $priority, $hook->callbacks );
|
||||
$this->assertCount( 1, $hook->callbacks[ $priority + 1 ] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,11 +255,14 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
|
||||
$headers[ $parts[0] ] = $parts[1];
|
||||
}
|
||||
|
||||
$this->assertTrue( isset( $headers['test1'] ) && 'test' === $headers['test1'] );
|
||||
$this->assertTrue( isset( $headers['test2'] ) && '0' === $headers['test2'] );
|
||||
$this->assertArrayHasKey( 'test1', $headers );
|
||||
$this->assertSame( 'test', $headers['test1'] );
|
||||
$this->assertArrayHasKey( 'test2', $headers );
|
||||
$this->assertSame( '0', $headers['test2'] );
|
||||
// cURL/HTTP Extension Note: Will never pass, cURL does not pass headers with an empty value.
|
||||
// Should it be that empty headers with empty values are NOT sent?
|
||||
// $this->assertTrue( isset( $headers['test3'] ) && '' === $headers['test3'] );
|
||||
// $this->assertArrayHasKey( 'test3', $headers );
|
||||
// $this->assertSame( '', $headers['test3'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -313,7 +313,7 @@ class Tests_HTTP_HTTP extends WP_UnitTestCase {
|
||||
|
||||
foreach ( array_keys( $cookies ) as $cookie ) {
|
||||
if ( 'foo' === $cookie ) {
|
||||
$this->assertFalse( isset( $cookie_jar[ $cookie ] ) );
|
||||
$this->assertArrayNotHasKey( $cookie, $cookie_jar );
|
||||
} else {
|
||||
$this->assertInstanceOf( 'Requests_Cookie', $cookie_jar[ $cookie ] );
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$metadata = wp_generate_attachment_metadata( $attachment_id, $test_file );
|
||||
$this->assertTrue( isset( $metadata['sizes']['test-size'] ), 'The `test-size` was not added to the metadata.' );
|
||||
$this->assertArrayHasKey( 'test-size', $metadata['sizes'], 'The `test-size` was not added to the metadata.' );
|
||||
$this->assertSame( $metadata['sizes']['test-size'], $expected );
|
||||
|
||||
remove_image_size( 'test-size' );
|
||||
|
||||
@@ -59,7 +59,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase {
|
||||
$this->assertSame( 75, $image['height'] );
|
||||
$this->assertSame( 'image/jpeg', $image['mime-type'] );
|
||||
|
||||
$this->assertFalse( isset( $image['path'] ) );
|
||||
$this->assertArrayNotHasKey( 'path', $image );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -227,7 +227,7 @@ class Tests_TestHelpers extends WP_UnitTestCase {
|
||||
|
||||
$stati = get_post_stati();
|
||||
|
||||
$this->assertFalse( isset( $stati['foo'] ) );
|
||||
$this->assertArrayNotHasKey( 'foo', $stati );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -507,7 +507,7 @@ EOF;
|
||||
$this->assertTrue( $tags['a']['rel'] );
|
||||
|
||||
$tags = wp_kses_allowed_html();
|
||||
$this->assertFalse( isset( $tags['a']['rel'] ) );
|
||||
$this->assertArrayNotHasKey( 'rel', $tags['a'] );
|
||||
|
||||
$this->assertSame( array(), wp_kses_allowed_html( 'strip' ) );
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@ https://w.org</a>',
|
||||
|
||||
$prepped = wp_prepare_attachment_for_js( get_post( $id ) );
|
||||
|
||||
$this->assertTrue( isset( $prepped['sizes'] ) );
|
||||
$this->assertArrayHasKey( 'sizes', $prepped );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,7 +146,7 @@ class Tests_Meta_Query extends WP_UnitTestCase {
|
||||
$query = new WP_Meta_Query();
|
||||
$query->parse_query_vars( $qv );
|
||||
|
||||
$this->assertTrue( ! isset( $query->queries[0]['value'] ) );
|
||||
$this->assertArrayNotHasKey( 'value', $query->queries[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +163,7 @@ class Tests_Meta_Query extends WP_UnitTestCase {
|
||||
$query = new WP_Meta_Query();
|
||||
$query->parse_query_vars( $qv );
|
||||
|
||||
$this->assertTrue( ! isset( $query->queries[0]['value'] ) );
|
||||
$this->assertArrayNotHasKey( 'value', $query->queries[0] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,8 @@ class Tests_Filter_oEmbed_Result extends WP_UnitTestCase {
|
||||
$matches = array();
|
||||
preg_match( '|src=".*#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches );
|
||||
|
||||
$this->assertTrue( isset( $matches[1] ) );
|
||||
$this->assertTrue( isset( $matches[2] ) );
|
||||
$this->assertArrayHasKey( 1, $matches );
|
||||
$this->assertArrayHasKey( 2, $matches );
|
||||
$this->assertSame( $matches[1], $matches[2] );
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ EOD;
|
||||
$matches = array();
|
||||
preg_match( '|src="https://wordpress.org#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches );
|
||||
|
||||
$this->assertTrue( isset( $matches[1] ) );
|
||||
$this->assertTrue( isset( $matches[2] ) );
|
||||
$this->assertArrayHasKey( 1, $matches );
|
||||
$this->assertArrayHasKey( 2, $matches );
|
||||
$this->assertSame( $matches[1], $matches[2] );
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase {
|
||||
|
||||
$options = wp_load_alloptions();
|
||||
|
||||
$this->assertFalse( isset( $options[ $key ] ) );
|
||||
$this->assertArrayNotHasKey( $key, $options );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ class Tests_Option_NetworkOption extends WP_UnitTestCase {
|
||||
|
||||
$options = wp_load_alloptions();
|
||||
|
||||
$this->assertFalse( isset( $options[ $key ] ) );
|
||||
$this->assertArrayNotHasKey( $key, $options );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -56,6 +56,6 @@ class Tests_Option_SiteTransient extends WP_UnitTestCase {
|
||||
|
||||
$options = wp_load_alloptions();
|
||||
|
||||
$this->assertFalse( isset( $options[ '_site_transient_' . $key ] ) );
|
||||
$this->assertArrayNotHasKey( '_site_transient_' . $key, $options );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,7 +891,7 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
register_post_status( 'test' );
|
||||
|
||||
$counts = wp_count_posts();
|
||||
$this->assertTrue( isset( $counts->test ) );
|
||||
$this->assertObjectHasAttribute( 'test', $counts );
|
||||
$this->assertSame( 0, $counts->test );
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
|
||||
|
||||
$post = get_post( $id, ARRAY_N );
|
||||
$this->assertIsArray( $post );
|
||||
$this->assertFalse( isset( $post['post_type'] ) );
|
||||
$this->assertArrayNotHasKey( 'post_type', $post );
|
||||
$this->assertTrue( in_array( 'post', $post, true ) );
|
||||
|
||||
$post = get_post( $id );
|
||||
|
||||
@@ -394,9 +394,9 @@ class Tests_Post_Types extends WP_UnitTestCase {
|
||||
|
||||
$this->assertTrue( unregister_post_type( 'foo' ) );
|
||||
|
||||
$this->assertFalse( isset( $post_type_meta_caps['read_bar'] ) );
|
||||
$this->assertFalse( isset( $post_type_meta_caps['delete_bar'] ) );
|
||||
$this->assertFalse( isset( $post_type_meta_caps['edit_bar'] ) );
|
||||
$this->assertArrayNotHasKey( 'read_bar', $post_type_meta_caps );
|
||||
$this->assertArrayNotHasKey( 'delete_bar', $post_type_meta_caps );
|
||||
$this->assertArrayNotHasKey( 'edit_bar', $post_type_meta_caps );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,7 +422,7 @@ class Tests_Post_Types extends WP_UnitTestCase {
|
||||
$_wp_post_type_features['foo']
|
||||
);
|
||||
$this->assertTrue( unregister_post_type( 'foo' ) );
|
||||
$this->assertFalse( isset( $_wp_post_type_features['foo'] ) );
|
||||
$this->assertArrayNotHasKey( 'foo', $_wp_post_type_features );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -504,7 +504,7 @@ class Tests_Post_Types extends WP_UnitTestCase {
|
||||
|
||||
$this->assertTrue( unregister_post_type( 'foo' ) );
|
||||
|
||||
$this->assertFalse( isset( $wp_post_types['foo'] ) );
|
||||
$this->assertArrayNotHasKey( 'foo', $wp_post_types );
|
||||
$this->assertNull( get_post_type_object( 'foo' ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
true
|
||||
);
|
||||
$endpoints = $GLOBALS['wp_rest_server']->get_routes();
|
||||
$this->assertFalse( isset( $endpoints['/test-empty-namespace'] ) );
|
||||
$this->assertArrayNotHasKey( '/test-empty-namespace', $endpoints );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +257,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
true
|
||||
);
|
||||
$endpoints = $GLOBALS['wp_rest_server']->get_routes();
|
||||
$this->assertFalse( isset( $endpoints['/test-empty-route'] ) );
|
||||
$this->assertArrayNotHasKey( '/test-empty-route', $endpoints );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -951,7 +951,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$this->assertSame( array_keys( $preload_data ), array( '/wp/v2/types', 'OPTIONS' ) );
|
||||
$this->assertTrue( isset( $preload_data['OPTIONS']['/wp/v2/media'] ) );
|
||||
$this->assertArrayHasKey( '/wp/v2/media', $preload_data['OPTIONS'] );
|
||||
|
||||
$GLOBALS['wp_rest_server'] = $rest_server;
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
remove_image_size( 'rest-api-test' );
|
||||
|
||||
$this->assertIsArray( $data['media_details']['sizes'], 'Could not retrieve the sizes data.' );
|
||||
$this->assertFalse( isset( $data['media_details']['sizes']['rest-api-test']['source_url'] ) );
|
||||
$this->assertArrayNotHasKey( 'source_url', $data['media_details']['sizes']['rest-api-test'] );
|
||||
}
|
||||
|
||||
public function test_get_item_private_post_not_authenticated() {
|
||||
@@ -1686,10 +1686,10 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$this->assertSame( $attachment->post_excerpt, $data['caption']['raw'] );
|
||||
$this->assertSame( $attachment->post_content, $data['description']['raw'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['caption']['raw'] ) );
|
||||
$this->assertFalse( isset( $data['description']['raw'] ) );
|
||||
$this->assertArrayNotHasKey( 'raw', $data['caption'] );
|
||||
$this->assertArrayNotHasKey( 'raw', $data['description'] );
|
||||
}
|
||||
$this->assertTrue( isset( $data['media_details'] ) );
|
||||
$this->assertArrayHasKey( 'media_details', $data );
|
||||
|
||||
if ( $attachment->post_parent ) {
|
||||
$this->assertSame( $attachment->post_parent, $data['post'] );
|
||||
|
||||
@@ -747,7 +747,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertArrayHasKey( 'meta', $data );
|
||||
|
||||
$meta = (array) $data['meta'];
|
||||
$this->assertFalse( isset( $meta['test_tag_meta'] ) );
|
||||
$this->assertArrayNotHasKey( 'test_tag_meta', $meta );
|
||||
}
|
||||
|
||||
public function test_get_term_invalid_taxonomy() {
|
||||
@@ -942,7 +942,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertSame( 'new-slug', $data['slug'] );
|
||||
$this->assertSame( 'just meta', $data['meta']['test_single'] );
|
||||
$this->assertSame( 'category-specific meta', $data['meta']['test_cat_single'] );
|
||||
$this->assertFalse( isset( $data['meta']['test_tag_meta'] ) );
|
||||
$this->assertArrayNotHasKey( 'test_tag_meta', $data['meta'] );
|
||||
}
|
||||
|
||||
public function test_update_item_invalid_taxonomy() {
|
||||
@@ -1209,7 +1209,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
|
||||
if ( $taxonomy->hierarchical ) {
|
||||
$this->assertSame( $term->parent, $data['parent'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $term->parent ) );
|
||||
$this->assertObjectNotHasProperty( 'parent', $term );
|
||||
}
|
||||
|
||||
$relations = array(
|
||||
|
||||
@@ -249,7 +249,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
$args = rest_get_endpoint_args_for_schema( $controller->get_item_schema() );
|
||||
|
||||
$this->assertSame( 'A pretty string.', $args['somestring']['description'] );
|
||||
$this->assertFalse( isset( $args['someinteger']['description'] ) );
|
||||
$this->assertArrayNotHasKey( 'description', $args['someinteger'] );
|
||||
}
|
||||
|
||||
public function test_get_endpoint_args_for_item_schema_arg_options() {
|
||||
|
||||
@@ -43,7 +43,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->check_post_type_obj( 'view', $post_types['post'], $data['post'], $data['post']['_links'] );
|
||||
$this->assertSame( $post_types['page']->name, $data['page']['slug'] );
|
||||
$this->check_post_type_obj( 'view', $post_types['page'], $data['page'], $data['page']['_links'] );
|
||||
$this->assertFalse( isset( $data['revision'] ) );
|
||||
$this->assertArrayNotHasKey( 'revision', $data );
|
||||
}
|
||||
|
||||
public function test_get_items_invalid_permission_for_context() {
|
||||
@@ -218,10 +218,10 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertSame( $viewable, $data['viewable'] );
|
||||
$this->assertSame( get_all_post_type_supports( $post_type_obj->name ), $data['supports'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['capabilities'] ) );
|
||||
$this->assertFalse( isset( $data['viewable'] ) );
|
||||
$this->assertFalse( isset( $data['labels'] ) );
|
||||
$this->assertFalse( isset( $data['supports'] ) );
|
||||
$this->assertArrayNotHasKey( 'capabilities', $data );
|
||||
$this->assertArrayNotHasKey( 'viewable', $data );
|
||||
$this->assertArrayNotHasKey( 'labels', $data );
|
||||
$this->assertArrayNotHasKey( 'supports', $data );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1777,7 +1777,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
|
||||
$this->assertSame( rest_url( '/wp/v2/posts/' . self::$post_id . '/revisions' ), $links['version-history'][0]['href'] );
|
||||
$this->assertSame( 0, $links['version-history'][0]['attributes']['count'] );
|
||||
$this->assertFalse( isset( $links['predecessor-version'] ) );
|
||||
$this->assertArrayNotHasKey( 'predecessor-version', $links );
|
||||
|
||||
$attachments_url = rest_url( '/wp/v2/media' );
|
||||
$attachments_url = add_query_arg( 'parent', self::$post_id, $attachments_url );
|
||||
@@ -1833,7 +1833,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$links = $response->get_links();
|
||||
$this->assertFalse( isset( $links['author'] ) );
|
||||
$this->assertArrayNotHasKey( 'author', $links );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => self::$post_id,
|
||||
@@ -2030,7 +2030,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $post_id ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertFalse( isset( $data['content']['block_version'] ) );
|
||||
$this->assertArrayNotHasKey( 'block_version', $data['content'] );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4157,7 +4157,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
);
|
||||
create_initial_rest_routes();
|
||||
$routes = rest_get_server()->get_routes();
|
||||
$this->assertFalse( isset( $routes['/wp/v2/invalid-controller'] ) );
|
||||
$this->assertArrayNotHasKey( '/wp/v2/invalid-controller', $routes );
|
||||
_unregister_post_type( 'invalid-controller' );
|
||||
|
||||
}
|
||||
|
||||
@@ -1118,12 +1118,12 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->assertTrue( isset( $headers[ $header ] ), sprintf( 'Header %s is not present in the response.', $header ) );
|
||||
$this->assertArrayHasKey( $header, $headers, sprintf( 'Header %s is not present in the response.', $header ) );
|
||||
$this->assertSame( $value, $headers[ $header ] );
|
||||
}
|
||||
|
||||
// Last-Modified should be unset as per #WP23021.
|
||||
$this->assertFalse( isset( $headers['Last-Modified'] ), 'Last-Modified should not be sent.' );
|
||||
$this->assertArrayNotHasKey( 'Last-Modified', $headers, 'Last-Modified should not be sent.' );
|
||||
}
|
||||
|
||||
public function test_no_nocache_headers_on_unauthenticated_requests() {
|
||||
|
||||
@@ -700,7 +700,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$this->assertArrayHasKey( 'meta', $data );
|
||||
|
||||
$meta = (array) $data['meta'];
|
||||
$this->assertFalse( isset( $meta['test_cat_meta'] ) );
|
||||
$this->assertArrayNotHasKey( 'test_cat_meta', $meta );
|
||||
}
|
||||
|
||||
public function test_get_term_invalid_term() {
|
||||
@@ -874,7 +874,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$this->assertSame( 'new-slug', $data['slug'] );
|
||||
$this->assertSame( 'just meta', $data['meta']['test_single'] );
|
||||
$this->assertSame( 'tag-specific meta', $data['meta']['test_tag_single'] );
|
||||
$this->assertFalse( isset( $data['meta']['test_cat_meta'] ) );
|
||||
$this->assertArrayNotHasKey( 'test_cat_meta', $data['meta'] );
|
||||
}
|
||||
|
||||
public function test_update_item_no_change() {
|
||||
@@ -1242,7 +1242,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$data = $response->get_data();
|
||||
$properties = $data['schema']['properties'];
|
||||
$this->assertArrayHasKey( 'id', $properties );
|
||||
$this->assertFalse( isset( $properties['parent'] ) );
|
||||
$this->assertArrayNotHasKey( 'parent', $properties );
|
||||
}
|
||||
|
||||
public function test_get_additional_field_registration() {
|
||||
@@ -1427,7 +1427,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
if ( $taxonomy->hierarchical ) {
|
||||
$this->assertSame( $term->parent, $data['parent'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['parent'] ) );
|
||||
$this->assertArrayNotHasKey( 'parent', $data );
|
||||
}
|
||||
$expected_links = array(
|
||||
'self',
|
||||
|
||||
@@ -266,10 +266,10 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$this->assertSame( $tax_obj->show_in_quick_edit, $data['visibility']['show_in_quick_edit'] );
|
||||
$this->assertSame( $tax_obj->show_ui, $data['visibility']['show_ui'] );
|
||||
} else {
|
||||
$this->assertFalse( isset( $data['capabilities'] ) );
|
||||
$this->assertFalse( isset( $data['labels'] ) );
|
||||
$this->assertFalse( isset( $data['show_cloud'] ) );
|
||||
$this->assertFalse( isset( $data['visibility'] ) );
|
||||
$this->assertArrayNotHasKey( 'capabilities', $data );
|
||||
$this->assertArrayNotHasKey( 'labels', $data );
|
||||
$this->assertArrayNotHasKey( 'show_cloud', $data );
|
||||
$this->assertArrayNotHasKey( 'visibility', $data );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1029,8 +1029,8 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
remove_theme_support( 'post-formats' );
|
||||
$response = self::perform_active_theme_request();
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertTrue( isset( $result[0]['theme_supports']['formats'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertArrayHasKey( 'formats', $result[0]['theme_supports'] );
|
||||
$this->assertSame( array( 'standard' ), $result[0]['theme_supports']['formats'] );
|
||||
}
|
||||
|
||||
@@ -1043,8 +1043,8 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
add_theme_support( 'post-formats', array( 'aside', 'video' ) );
|
||||
$response = self::perform_active_theme_request();
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertTrue( isset( $result[0]['theme_supports']['formats'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertArrayHasKey( 'formats', $result[0]['theme_supports'] );
|
||||
$this->assertSame( array( 'standard', 'aside', 'video' ), $result[0]['theme_supports']['formats'] );
|
||||
}
|
||||
|
||||
@@ -1058,8 +1058,8 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$response = self::perform_active_theme_request();
|
||||
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertTrue( isset( $result[0]['theme_supports']['responsive-embeds'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertArrayHasKey( 'responsive-embeds', $result[0]['theme_supports'] );
|
||||
$this->assertFalse( $result[0]['theme_supports']['responsive-embeds'] );
|
||||
}
|
||||
|
||||
@@ -1073,7 +1073,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
add_theme_support( 'responsive-embeds' );
|
||||
$response = self::perform_active_theme_request();
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertTrue( $result[0]['theme_supports']['responsive-embeds'] );
|
||||
}
|
||||
|
||||
@@ -1087,8 +1087,8 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$response = self::perform_active_theme_request();
|
||||
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertTrue( isset( $result[0]['theme_supports']['post-thumbnails'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertArrayHasKey( 'post-thumbnails', $result[0]['theme_supports'] );
|
||||
$this->assertFalse( $result[0]['theme_supports']['post-thumbnails'] );
|
||||
}
|
||||
|
||||
@@ -1102,7 +1102,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
$response = self::perform_active_theme_request();
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertTrue( $result[0]['theme_supports']['post-thumbnails'] );
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
add_theme_support( 'post-thumbnails', array( 'post' ) );
|
||||
$response = self::perform_active_theme_request();
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertSame( array( 'post' ), $result[0]['theme_supports']['post-thumbnails'] );
|
||||
}
|
||||
|
||||
@@ -1142,7 +1142,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
|
||||
$response = self::perform_active_theme_request();
|
||||
$result = $response->get_data();
|
||||
$this->assertTrue( isset( $result[0]['theme_supports'] ) );
|
||||
$this->assertArrayHasKey( 'theme_supports', $result[0] );
|
||||
$this->assertSame( array( 'a', 'b', 'c' ), $result[0]['theme_supports']['test-feature'] );
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,6 @@ class Tests_Rewrite_Permastructs extends WP_UnitTestCase {
|
||||
$this->assertSame( '/bar/%foo%', $wp_rewrite->extra_permastructs['foo']['struct'] );
|
||||
|
||||
remove_permastruct( 'foo' );
|
||||
$this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) );
|
||||
$this->assertArrayNotHasKey( 'foo', $wp_rewrite->extra_permastructs );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class Test_WP_Sitemaps_Posts extends WP_UnitTestCase {
|
||||
$url_list = $posts_provider->get_url_list( 1, 'page' );
|
||||
$sitemap_entry = array_shift( $url_list );
|
||||
|
||||
$this->assertTrue( isset( $sitemap_entry['lastmod'] ) );
|
||||
$this->assertArrayHasKey( 'lastmod', $sitemap_entry );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -842,7 +842,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
|
||||
|
||||
$this->assertIsArray( $wp_rewrite->extra_permastructs['foo'] );
|
||||
$this->assertTrue( unregister_taxonomy( 'foo' ) );
|
||||
$this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) );
|
||||
$this->assertArrayNotHasKey( 'foo', $wp_rewrite->extra_permastructs );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -878,7 +878,7 @@ class Tests_Taxonomy extends WP_UnitTestCase {
|
||||
|
||||
$this->assertTrue( unregister_taxonomy( 'foo' ) );
|
||||
|
||||
$this->assertFalse( isset( $wp_taxonomies['foo'] ) );
|
||||
$this->assertArrayNotHasKey( 'foo', $wp_taxonomies );
|
||||
$this->assertFalse( get_taxonomy( 'foo' ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -104,14 +104,14 @@ class Tests_Term_GetTerm extends WP_UnitTestCase {
|
||||
$t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
|
||||
$term = get_term( $t, 'wptests_tax', ARRAY_A );
|
||||
$this->assertIsArray( $term );
|
||||
$this->assertTrue( isset( $term['term_id'] ) );
|
||||
$this->assertArrayHasKey( 'term_id', $term );
|
||||
}
|
||||
|
||||
public function test_output_array_n() {
|
||||
$t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
|
||||
$term = get_term( $t, 'wptests_tax', ARRAY_N );
|
||||
$this->assertIsArray( $term );
|
||||
$this->assertFalse( isset( $term['term_id'] ) );
|
||||
$this->assertArrayNotHasKey( 'term_id', $term );
|
||||
foreach ( $term as $k => $v ) {
|
||||
$this->assertIsInt( $k );
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
$term = get_term( $t );
|
||||
$this->assertFalse( isset( $term->object_id ) );
|
||||
$this->assertObjectNotHasAttribute( 'object_id', $term );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -131,7 +131,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
'Theme Root URI' => 'Theme Root URI',
|
||||
);
|
||||
foreach ( $default_headers as $name => $value ) {
|
||||
$this->assertTrue( isset( $theme[ $name ] ) );
|
||||
$this->assertArrayHasKey( $name, $theme );
|
||||
}
|
||||
|
||||
// Make the tests work both for WordPress 2.8.5 and WordPress 2.9-rare.
|
||||
|
||||
@@ -166,7 +166,8 @@ class Tests_User extends WP_UnitTestCase {
|
||||
// For reasons unclear, the resulting array is indexed numerically; meta keys are not included anywhere.
|
||||
// So we'll just check to make sure our values are included somewhere.
|
||||
foreach ( $vals as $k => $v ) {
|
||||
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
|
||||
$this->assertArrayHasKey( $k, $out );
|
||||
$this->assertSame( $v, $out[ $k ][0] );
|
||||
}
|
||||
// Delete one key and check again.
|
||||
$keys = array_keys( $vals );
|
||||
@@ -176,9 +177,10 @@ class Tests_User extends WP_UnitTestCase {
|
||||
// Make sure that key is excluded from the results.
|
||||
foreach ( $vals as $k => $v ) {
|
||||
if ( $k === $key_to_delete ) {
|
||||
$this->assertFalse( isset( $out[ $k ] ) );
|
||||
$this->assertArrayNotHasKey( $k, $out );
|
||||
} else {
|
||||
$this->assertTrue( isset( $out[ $k ] ) && $out[ $k ][0] === $v );
|
||||
$this->assertArrayHasKey( $k, $out );
|
||||
$this->assertSame( $v, $out[ $k ][0] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1608,11 +1608,11 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||
$author = self::$users['author'];
|
||||
|
||||
$author->add_cap( 'foo', false );
|
||||
$this->assertTrue( isset( $author->caps['foo'] ) );
|
||||
$this->assertArrayHasKey( 'foo', $author->caps );
|
||||
$this->assertFalse( user_can( $author->ID, 'foo' ) );
|
||||
|
||||
$author->remove_cap( 'foo' );
|
||||
$this->assertFalse( isset( $author->caps['foo'] ) );
|
||||
$this->assertArrayNotHasKey( 'foo', $author->caps );
|
||||
$this->assertFalse( user_can( $author->ID, 'foo' ) );
|
||||
}
|
||||
|
||||
@@ -2237,7 +2237,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||
$wp_roles = wp_roles();
|
||||
$wp_roles->for_site( $site_id );
|
||||
|
||||
$this->assertTrue( isset( $wp_roles->role_objects[ $role_name ] ) );
|
||||
$this->assertArrayHasKey( $role_name, $wp_roles->role_objects );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,15 +72,15 @@ if ( is_multisite() ) :
|
||||
// Each site retrieved should match the expected structure.
|
||||
foreach ( $blogs_of_user as $blog_id => $blog ) {
|
||||
$this->assertSame( $blog_id, $blog->userblog_id );
|
||||
$this->assertTrue( isset( $blog->userblog_id ) );
|
||||
$this->assertTrue( isset( $blog->blogname ) );
|
||||
$this->assertTrue( isset( $blog->domain ) );
|
||||
$this->assertTrue( isset( $blog->path ) );
|
||||
$this->assertTrue( isset( $blog->site_id ) );
|
||||
$this->assertTrue( isset( $blog->siteurl ) );
|
||||
$this->assertTrue( isset( $blog->archived ) );
|
||||
$this->assertTrue( isset( $blog->spam ) );
|
||||
$this->assertTrue( isset( $blog->deleted ) );
|
||||
$this->assertObjectHasAttribute( 'userblog_id', $blog );
|
||||
$this->assertObjectHasAttribute( 'blogname', $blog );
|
||||
$this->assertObjectHasAttribute( 'domain', $blog );
|
||||
$this->assertObjectHasAttribute( 'path', $blog );
|
||||
$this->assertObjectHasAttribute( 'site_id', $blog );
|
||||
$this->assertObjectHasAttribute( 'siteurl', $blog );
|
||||
$this->assertObjectHasAttribute( 'archived', $blog );
|
||||
$this->assertObjectHasAttribute( 'spam', $blog );
|
||||
$this->assertObjectHasAttribute( 'deleted', $blog );
|
||||
}
|
||||
|
||||
// Mark each remaining site as spam, archived, and deleted.
|
||||
|
||||
@@ -134,7 +134,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
|
||||
register_sidebars( 1, array( 'id' => 'wp-unit-test' ) );
|
||||
|
||||
$this->assertTrue( isset( $wp_registered_sidebars['wp-unit-test'] ) );
|
||||
$this->assertArrayHasKey( 'wp-unit-test', $wp_registered_sidebars );
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user