mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Use more appropriate assertions in various tests.
This replaces instances of `assertTrue( in_array( ... ) )` with `assertContains()` to use native PHPUnit functionality. Follow-up to [51335], [51337], [51367], [51397], [51403]. Props hellofromTonya, jrf, SergeyBiryukov. Fixes #53123. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51404 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5d9a38ef41
commit
c96a42e08a
@ -108,7 +108,7 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
|
||||
|
||||
// Check for either possible total.
|
||||
$message = sprintf( 'returned value: %1$d $total: %2$d $recalc_total: %3$d', (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], $total, $recalc_total );
|
||||
$this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ), true ), $message );
|
||||
$this->assertContains( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ), $message );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -103,7 +103,7 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase {
|
||||
$total = $_POST['_total'] - 1;
|
||||
|
||||
// Check for either possible total.
|
||||
$this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ), true ) );
|
||||
$this->assertContains( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -83,7 +83,7 @@ class Tests_Ajax_Response extends WP_UnitTestCase {
|
||||
$headers = xdebug_get_headers();
|
||||
ob_end_clean();
|
||||
|
||||
$this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers, true ) );
|
||||
$this->assertContains( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -186,7 +186,7 @@ class Tests_Feeds_Atom extends WP_UnitTestCase {
|
||||
}
|
||||
$categories = xml_find( $entries[ $key ]['child'], 'category' );
|
||||
foreach ( $categories as $category ) {
|
||||
$this->assertTrue( in_array( $category['attributes']['term'], $terms, true ) );
|
||||
$this->assertContains( $category['attributes']['term'], $terms );
|
||||
}
|
||||
unset( $terms );
|
||||
|
||||
|
||||
@ -127,10 +127,10 @@ class Tests_Formatting_EscUrl extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
$this->assertTrue( ! in_array( 'data', wp_allowed_protocols(), true ) );
|
||||
$this->assertNotContains( 'data', wp_allowed_protocols() );
|
||||
$this->assertSame( '', esc_url( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) );
|
||||
|
||||
$this->assertTrue( ! in_array( 'foo', wp_allowed_protocols(), true ) );
|
||||
$this->assertNotContains( 'foo', wp_allowed_protocols() );
|
||||
$this->assertSame(
|
||||
'foo://example.com',
|
||||
esc_url(
|
||||
|
||||
@ -31,6 +31,6 @@ class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {
|
||||
|
||||
$headers = xdebug_get_headers();
|
||||
|
||||
$this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers, true ) );
|
||||
$this->assertContains( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers );
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ class Tests_Pluggable extends WP_UnitTestCase {
|
||||
foreach ( $expected as $function => $sig ) {
|
||||
$msg = 'Function: ' . $function . '()';
|
||||
$this->assertTrue( function_exists( $function ), $msg );
|
||||
$this->assertTrue( in_array( $function, $defined, true ), $msg );
|
||||
$this->assertContains( $function, $defined, $msg );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ class Tests_Post_Meta extends WP_UnitTestCase {
|
||||
'another value',
|
||||
);
|
||||
sort( $expected );
|
||||
$this->assertTrue( in_array( get_post_meta( self::$post_id, 'nonunique', true ), $expected, true ) );
|
||||
$this->assertContains( get_post_meta( self::$post_id, 'nonunique', true ), $expected );
|
||||
$actual = get_post_meta( self::$post_id, 'nonunique', false );
|
||||
sort( $actual );
|
||||
$this->assertSame( $expected, $actual );
|
||||
|
||||
@ -36,7 +36,7 @@ class Tests_Post_Objects extends WP_UnitTestCase {
|
||||
$post = get_post( $id, ARRAY_N );
|
||||
$this->assertIsArray( $post );
|
||||
$this->assertArrayNotHasKey( 'post_type', $post );
|
||||
$this->assertTrue( in_array( 'post', $post, true ) );
|
||||
$this->assertContains( 'post', $post );
|
||||
|
||||
$post = get_post( $id );
|
||||
$post = get_post( $post, ARRAY_A );
|
||||
|
||||
@ -119,7 +119,7 @@ class Tests_Post_WP_Post_Type extends WP_UnitTestCase {
|
||||
);
|
||||
$post_type_object->add_rewrite_rules();
|
||||
|
||||
$this->assertFalse( in_array( 'foobar', $wp->public_query_vars, true ) );
|
||||
$this->assertNotContains( 'foobar', $wp->public_query_vars );
|
||||
}
|
||||
|
||||
public function test_adds_query_var_if_public() {
|
||||
|
||||
@ -265,7 +265,7 @@ class Tests_REST_API extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_rest_route_query_var() {
|
||||
rest_api_init();
|
||||
$this->assertTrue( in_array( 'rest_route', $GLOBALS['wp']->public_query_vars, true ) );
|
||||
$this->assertContains( 'rest_route', $GLOBALS['wp']->public_query_vars );
|
||||
}
|
||||
|
||||
public function test_route_method() {
|
||||
|
||||
@ -302,9 +302,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$data = $response->get_data();
|
||||
$this->assertCount( 2, $data );
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id3, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
$this->assertContains( $id3, $ids );
|
||||
|
||||
$this->check_get_posts_response( $response );
|
||||
}
|
||||
@ -343,9 +343,9 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control
|
||||
$data = $response->get_data();
|
||||
$this->assertCount( 3, $data );
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id2, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id3, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertContains( $id2, $ids );
|
||||
$this->assertContains( $id3, $ids );
|
||||
}
|
||||
|
||||
public function test_get_items_media_type() {
|
||||
|
||||
@ -311,15 +311,15 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertContains( $id2, $ids );
|
||||
|
||||
$request->set_param( 'exclude', array( $id2 ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
}
|
||||
|
||||
public function test_get_items_orderby_args() {
|
||||
|
||||
@ -247,7 +247,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertTrue( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertContains( $password_comment, wp_list_pluck( $collection_data, 'id' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -270,7 +270,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertFalse( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertNotContains( $password_comment, wp_list_pluck( $collection_data, 'id' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,7 +310,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertFalse( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertNotContains( $password_comment, wp_list_pluck( $collection_data, 'id' ) );
|
||||
}
|
||||
|
||||
public function test_get_password_items_with_edit_post_permission() {
|
||||
@ -329,7 +329,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertTrue( in_array( $password_comment, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertContains( $password_comment, wp_list_pluck( $collection_data, 'id' ) );
|
||||
}
|
||||
|
||||
public function test_get_items_without_private_post_permission() {
|
||||
@ -348,7 +348,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertFalse( in_array( $private_comment, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertNotContains( $private_comment, wp_list_pluck( $collection_data, 'id' ) );
|
||||
}
|
||||
|
||||
public function test_get_items_with_private_post_permission() {
|
||||
@ -367,7 +367,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertTrue( in_array( $private_comment, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertContains( $private_comment, wp_list_pluck( $collection_data, 'id' ) );
|
||||
}
|
||||
|
||||
public function test_get_items_with_invalid_post() {
|
||||
@ -386,7 +386,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertFalse( in_array( $comment_id, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertNotContains( $comment_id, wp_list_pluck( $collection_data, 'id' ) );
|
||||
|
||||
wp_delete_comment( $comment_id );
|
||||
}
|
||||
@ -407,7 +407,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$this->assertSame( 200, $response->get_status() );
|
||||
|
||||
$collection_data = $response->get_data();
|
||||
$this->assertTrue( in_array( $comment_id, wp_list_pluck( $collection_data, 'id' ), true ) );
|
||||
$this->assertContains( $comment_id, wp_list_pluck( $collection_data, 'id' ) );
|
||||
|
||||
wp_delete_comment( $comment_id );
|
||||
}
|
||||
@ -525,15 +525,15 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertContains( $id2, $ids );
|
||||
|
||||
$request->set_param( 'exclude', array( $id2 ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
|
||||
// Invalid 'exclude' should error.
|
||||
$request->set_param( 'exclude', array( 'invalid' ) );
|
||||
|
||||
@ -475,22 +475,22 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertContains( $id2, $ids );
|
||||
|
||||
$request->set_param( 'exclude', array( $id2 ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
|
||||
$request->set_param( 'exclude', (string) $id2 );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
|
||||
$request->set_param( 'exclude', 'invalid' );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
@ -1482,9 +1482,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
|
||||
$posts = $response->get_data();
|
||||
$ids = wp_list_pluck( $posts, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id3, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
$this->assertNotContains( $id3, $ids);
|
||||
|
||||
$this->assertPostsWhere( " AND {posts}.ID NOT IN ($id3,$id2) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" );
|
||||
}
|
||||
@ -1508,9 +1508,9 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
|
||||
$posts = $response->get_data();
|
||||
$ids = wp_list_pluck( $posts, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id2, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id3, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertContains( $id2, $ids );
|
||||
$this->assertNotContains( $id3, $ids );
|
||||
|
||||
$this->assertPostsWhere( " AND {posts}.ID NOT IN ($id3) AND {posts}.post_type = 'post' AND (({posts}.post_status = 'publish'))" );
|
||||
}
|
||||
|
||||
@ -616,8 +616,8 @@ class Tests_REST_Request extends WP_UnitTestCase {
|
||||
|
||||
$data = $valid->get_error_data( 'rest_missing_callback_param' );
|
||||
|
||||
$this->assertTrue( in_array( 'someinteger', $data['params'], true ) );
|
||||
$this->assertTrue( in_array( 'someotherinteger', $data['params'], true ) );
|
||||
$this->assertContains( 'someinteger', $data['params'] );
|
||||
$this->assertContains( 'someotherinteger', $data['params'] );
|
||||
}
|
||||
|
||||
public function test_has_valid_params_validate_callback() {
|
||||
|
||||
@ -245,15 +245,15 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertContains( $id2, $ids );
|
||||
|
||||
$request->set_param( 'exclude', array( $id2 ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
|
||||
// Invalid 'exclude' should error.
|
||||
$request->set_param( 'exclude', array( 'invalid' ) );
|
||||
|
||||
@ -277,9 +277,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
|
||||
$user_ids = wp_list_pluck( $users, 'id' );
|
||||
|
||||
$this->assertTrue( in_array( self::$editor, $user_ids, true ) );
|
||||
$this->assertTrue( in_array( self::$authors['r_true_p_true'], $user_ids, true ) );
|
||||
$this->assertTrue( in_array( self::$authors['r_true_p_false'], $user_ids, true ) );
|
||||
$this->assertContains( self::$editor, $user_ids );
|
||||
$this->assertContains( self::$authors['r_true_p_true'], $user_ids );
|
||||
$this->assertContains( self::$authors['r_true_p_false'], $user_ids );
|
||||
$this->assertCount( 3, $user_ids );
|
||||
}
|
||||
|
||||
@ -289,8 +289,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$users = $response->get_data();
|
||||
$user_ids = wp_list_pluck( $users, 'id' );
|
||||
|
||||
$this->assertFalse( in_array( self::$authors['r_false_p_true'], $user_ids, true ) );
|
||||
$this->assertFalse( in_array( self::$authors['r_false_p_false'], $user_ids, true ) );
|
||||
$this->assertNotContains( self::$authors['r_false_p_true'], $user_ids );
|
||||
$this->assertNotContains( self::$authors['r_false_p_false'], $user_ids );
|
||||
}
|
||||
|
||||
public function test_get_items_unauthenticated_does_not_include_users_without_published_posts() {
|
||||
@ -299,8 +299,8 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$users = $response->get_data();
|
||||
$user_ids = wp_list_pluck( $users, 'id' );
|
||||
|
||||
$this->assertFalse( in_array( self::$draft_editor, $user_ids, true ) );
|
||||
$this->assertFalse( in_array( self::$user, $user_ids, true ) );
|
||||
$this->assertNotContains( self::$draft_editor, $user_ids );
|
||||
$this->assertNotContains( self::$user, $user_ids );
|
||||
}
|
||||
|
||||
public function test_get_items_pagination_headers() {
|
||||
@ -633,15 +633,15 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertTrue( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertContains( $id2, $ids );
|
||||
|
||||
$request->set_param( 'exclude', array( $id2 ) );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$this->assertTrue( in_array( $id1, $ids, true ) );
|
||||
$this->assertFalse( in_array( $id2, $ids, true ) );
|
||||
$this->assertContains( $id1, $ids );
|
||||
$this->assertNotContains( $id2, $ids );
|
||||
|
||||
// Invalid 'exclude' should error.
|
||||
$request->set_param( 'exclude', 'none-of-those-please' );
|
||||
|
||||
@ -822,7 +822,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase {
|
||||
|
||||
$cached_children = get_option( 'wptests_tax_children' );
|
||||
$this->assertNotEmpty( $cached_children[ $t ] );
|
||||
$this->assertTrue( in_array( $found['term_id'], $cached_children[ $t ], true ) );
|
||||
$this->assertContains( $found['term_id'], $cached_children[ $t ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,7 +22,7 @@ class Tests_WP_Taxonomy extends WP_UnitTestCase {
|
||||
$taxonomy_object = new WP_Taxonomy( $taxonomy, 'post' );
|
||||
|
||||
$taxonomy_object->add_rewrite_rules();
|
||||
$this->assertFalse( in_array( 'foobar', $wp->public_query_vars, true ) );
|
||||
$this->assertNotContains( 'foobar', $wp->public_query_vars );
|
||||
}
|
||||
|
||||
public function test_adds_query_var_if_public() {
|
||||
|
||||
@ -685,7 +685,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase {
|
||||
|
||||
$cached_children = get_option( 'wptests_tax_children' );
|
||||
$this->assertNotEmpty( $cached_children[ $t2 ] );
|
||||
$this->assertTrue( in_array( $found['term_id'], $cached_children[ $t2 ], true ) );
|
||||
$this->assertContains( $found['term_id'], $cached_children[ $t2 ] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -208,7 +208,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
$this->assertNotEmpty( $theme );
|
||||
|
||||
$templates = $theme['Template Files'];
|
||||
$this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates, true ) );
|
||||
$this->assertContains( $this->theme_root . '/page-templates/template-top-level.php', $templates );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1113,7 +1113,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
|
||||
$this->assertContains( (string) self::$contrib_id, $users );
|
||||
}
|
||||
|
||||
public function test_search_users_url() {
|
||||
@ -1124,7 +1124,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
|
||||
$this->assertContains( (string) self::$contrib_id, $users );
|
||||
}
|
||||
|
||||
public function test_search_users_email() {
|
||||
@ -1135,7 +1135,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
|
||||
$this->assertContains( (string) self::$contrib_id, $users );
|
||||
}
|
||||
|
||||
public function test_search_users_nicename() {
|
||||
@ -1146,7 +1146,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
|
||||
$this->assertContains( (string) self::$contrib_id, $users );
|
||||
}
|
||||
|
||||
public function test_search_users_display_name() {
|
||||
@ -1157,7 +1157,7 @@ class Tests_User extends WP_UnitTestCase {
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertTrue( in_array( (string) self::$contrib_id, $users, true ) );
|
||||
$this->assertContains( (string) self::$contrib_id, $users );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,15 +22,15 @@ class Tests_WP extends WP_UnitTestCase {
|
||||
$this->wp->add_query_var( 'test' );
|
||||
|
||||
$this->assertCount( $public_qv_count + 2, $this->wp->public_query_vars );
|
||||
$this->assertTrue( in_array( 'test', $this->wp->public_query_vars, true ) );
|
||||
$this->assertTrue( in_array( 'test2', $this->wp->public_query_vars, true ) );
|
||||
$this->assertContains( 'test', $this->wp->public_query_vars );
|
||||
$this->assertContains( 'test2', $this->wp->public_query_vars );
|
||||
}
|
||||
|
||||
public function test_remove_query_var() {
|
||||
$public_qv_count = count( $this->wp->public_query_vars );
|
||||
|
||||
$this->wp->add_query_var( 'test' );
|
||||
$this->assertTrue( in_array( 'test', $this->wp->public_query_vars, true ) );
|
||||
$this->assertContains( 'test', $this->wp->public_query_vars );
|
||||
$this->wp->remove_query_var( 'test' );
|
||||
|
||||
$this->assertCount( $public_qv_count, $this->wp->public_query_vars );
|
||||
|
||||
@ -445,7 +445,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertCount( 1, get_post_meta( $post_id, 'enclosure' ) );
|
||||
|
||||
// For good measure, check that the expected value is in the array.
|
||||
$this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
|
||||
$this->assertContains( $enclosure_string, get_post_meta( $post_id, 'enclosure' ) );
|
||||
|
||||
// Attempt to add a brand new enclosure via XML-RPC.
|
||||
$this->myxmlrpcserver->add_enclosure_if_new( $post_id, $new_enclosure );
|
||||
@ -455,10 +455,10 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
|
||||
// Check that the new enclosure is in the enclosure meta.
|
||||
$new_enclosure_string = "{$new_enclosure['url']}\n{$new_enclosure['length']}\n{$new_enclosure['type']}\n";
|
||||
$this->assertTrue( in_array( $new_enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
|
||||
$this->assertContains( $new_enclosure_string, get_post_meta( $post_id, 'enclosure' ) );
|
||||
|
||||
// Check that the old enclosure is in the enclosure meta.
|
||||
$this->assertTrue( in_array( $enclosure_string, get_post_meta( $post_id, 'enclosure' ), true ) );
|
||||
$this->assertContains( $enclosure_string, get_post_meta( $post_id, 'enclosure' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user