From e77691036d4905ec6084b40a3748d3cff061a21d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 7 Jul 2021 10:32:56 +0000 Subject: [PATCH] Tests: Use more appropriate assertions in various tests. This replaces instances of `assertSame( [number], count( ... ) )` with `assertCount()` to use native PHPUnit functionality. Follow-up to [51335], [51337]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51367 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/admin/includesScreen.php | 10 ++--- tests/phpunit/tests/ajax/CustomizeMenus.php | 2 +- tests/phpunit/tests/blocks/block-list.php | 2 +- tests/phpunit/tests/category.php | 2 +- tests/phpunit/tests/comment.php | 10 ++--- .../tests/comment/getCommentExcerpt.php | 4 +- tests/phpunit/tests/comment/query.php | 24 +++++------ tests/phpunit/tests/feed/rss2.php | 16 +++---- .../phpunit/tests/functions/wpListFilter.php | 14 +++---- tests/phpunit/tests/import/import.php | 16 +++---- tests/phpunit/tests/import/parser.php | 12 +++--- tests/phpunit/tests/meta.php | 4 +- .../phpunit/tests/multisite/networkQuery.php | 2 +- tests/phpunit/tests/multisite/siteQuery.php | 2 +- tests/phpunit/tests/pomo/mo.php | 10 ++--- tests/phpunit/tests/pomo/po.php | 2 +- tests/phpunit/tests/post.php | 6 +-- tests/phpunit/tests/post/formats.php | 16 +++---- tests/phpunit/tests/post/getPages.php | 18 ++++---- tests/phpunit/tests/post/objects.php | 10 ++--- tests/phpunit/tests/post/query.php | 2 +- tests/phpunit/tests/post/types.php | 6 +-- tests/phpunit/tests/query/metaQuery.php | 22 +++++----- tests/phpunit/tests/query/taxQuery.php | 16 +++---- .../rest-api/rest-attachments-controller.php | 12 +++--- .../rest-api/rest-autosaves-controller.php | 2 +- .../rest-api/rest-block-type-controller.php | 2 +- .../rest-api/rest-categories-controller.php | 32 +++++++------- .../rest-api/rest-comments-controller.php | 6 +-- .../tests/rest-api/rest-pages-controller.php | 18 ++++---- .../rest-post-statuses-controller.php | 6 +-- .../rest-api/rest-post-types-controller.php | 2 +- .../tests/rest-api/rest-posts-controller.php | 36 ++++++++-------- .../rest-api/rest-revisions-controller.php | 2 +- .../tests/rest-api/rest-search-controller.php | 2 +- .../tests/rest-api/rest-tags-controller.php | 22 +++++----- .../rest-api/rest-taxonomies-controller.php | 4 +- .../tests/rest-api/rest-themes-controller.php | 2 +- .../tests/rest-api/rest-users-controller.php | 30 ++++++------- .../rest-api/rest-widgets-controller.php | 2 +- tests/phpunit/tests/taxonomy.php | 4 +- tests/phpunit/tests/term.php | 14 +++---- tests/phpunit/tests/term/cache.php | 2 +- tests/phpunit/tests/term/getTerms.php | 26 ++++++------ tests/phpunit/tests/term/getTheTerms.php | 4 +- tests/phpunit/tests/term/meta.php | 2 +- tests/phpunit/tests/term/query.php | 4 +- tests/phpunit/tests/term/taxQuery.php | 2 +- tests/phpunit/tests/term/wpGetObjectTerms.php | 2 +- tests/phpunit/tests/term/wpSetObjectTerms.php | 12 +++--- .../tests/theme/wpThemeGetAllowedFilters.php | 2 +- tests/phpunit/tests/user.php | 14 +++---- tests/phpunit/tests/user/query.php | 42 +++++++++---------- tests/phpunit/tests/widgets.php | 2 +- tests/phpunit/tests/wp.php | 4 +- .../tests/xmlrpc/mt/getRecentPostTitles.php | 2 +- .../tests/xmlrpc/mw/getRecentPosts.php | 2 +- tests/phpunit/tests/xmlrpc/wp/editPost.php | 4 +- tests/phpunit/tests/xmlrpc/wp/getPost.php | 2 +- .../phpunit/tests/xmlrpc/wp/getPostTypes.php | 2 +- tests/phpunit/tests/xmlrpc/wp/getPosts.php | 10 ++--- tests/phpunit/tests/xmlrpc/wp/getTerms.php | 14 +++---- tests/phpunit/tests/xmlrpc/wp/getUsers.php | 2 +- 63 files changed, 291 insertions(+), 291 deletions(-) diff --git a/tests/phpunit/tests/admin/includesScreen.php b/tests/phpunit/tests/admin/includesScreen.php index 09432dedca..cb405a9b14 100644 --- a/tests/phpunit/tests/admin/includesScreen.php +++ b/tests/phpunit/tests/admin/includesScreen.php @@ -391,7 +391,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $this->assertSame( $screen->get_help_tab( $tab_4 ), $tab_4_args ); $tabs = $screen->get_help_tabs(); - $this->assertSame( 4, count( $tabs ) ); + $this->assertCount( 4, $tabs ); $this->assertArrayHasKey( $tab_1, $tabs ); $this->assertArrayHasKey( $tab_2, $tabs ); $this->assertArrayHasKey( $tab_3, $tabs ); @@ -411,19 +411,19 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase { $screen->remove_help_tab( $tab_1 ); $this->assertNull( $screen->get_help_tab( $tab_1 ) ); - $this->assertSame( 3, count( $screen->get_help_tabs() ) ); + $this->assertCount( 3, $screen->get_help_tabs() ); $screen->remove_help_tab( $tab_2 ); $this->assertNull( $screen->get_help_tab( $tab_2 ) ); - $this->assertSame( 2, count( $screen->get_help_tabs() ) ); + $this->assertCount( 2, $screen->get_help_tabs() ); $screen->remove_help_tab( $tab_3 ); $this->assertNull( $screen->get_help_tab( $tab_3 ) ); - $this->assertSame( 1, count( $screen->get_help_tabs() ) ); + $this->assertCount( 1, $screen->get_help_tabs() ); $screen->remove_help_tab( $tab_4 ); $this->assertNull( $screen->get_help_tab( $tab_4 ) ); - $this->assertSame( 0, count( $screen->get_help_tabs() ) ); + $this->assertCount( 0, $screen->get_help_tabs() ); $screen->remove_help_tabs(); $this->assertSame( array(), $screen->get_help_tabs() ); diff --git a/tests/phpunit/tests/ajax/CustomizeMenus.php b/tests/phpunit/tests/ajax/CustomizeMenus.php index 20f76be168..6dbf201089 100644 --- a/tests/phpunit/tests/ajax/CustomizeMenus.php +++ b/tests/phpunit/tests/ajax/CustomizeMenus.php @@ -579,7 +579,7 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { if ( isset( $post_args['search'] ) && 'test' === $post_args['search'] ) { $this->assertTrue( $response['success'] ); - $this->assertSame( 6, count( $response['data']['items'] ) ); + $this->assertCount( 6, $response['data']['items'] ); $item_ids = wp_list_pluck( $response['data']['items'], 'id' ); $this->assertContains( 'post-' . $included_auto_draft_post->ID, $item_ids ); $this->assertNotContains( 'post-' . $excluded_auto_draft_post->ID, $item_ids ); diff --git a/tests/phpunit/tests/blocks/block-list.php b/tests/phpunit/tests/blocks/block-list.php index b9ab45dbcf..ffefbfadac 100644 --- a/tests/phpunit/tests/blocks/block-list.php +++ b/tests/phpunit/tests/blocks/block-list.php @@ -106,7 +106,7 @@ class WP_Block_List_Test extends WP_UnitTestCase { $context = array(); $blocks = new WP_Block_List( $parsed_blocks, $context, $this->registry ); - $this->assertSame( 1, count( $blocks ) ); + $this->assertCount( 1, $blocks ); } } diff --git a/tests/phpunit/tests/category.php b/tests/phpunit/tests/category.php index 824bb68c73..698e56dc7b 100644 --- a/tests/phpunit/tests/category.php +++ b/tests/phpunit/tests/category.php @@ -29,7 +29,7 @@ class Tests_Category extends WP_UnitTestCase { // Validate length is 1 + created due to uncategorized. $cat_ids = get_all_category_ids(); - $this->assertSame( 3, count( $cat_ids ) ); + $this->assertCount( 3, $cat_ids ); } /** diff --git a/tests/phpunit/tests/comment.php b/tests/phpunit/tests/comment.php index c3013ad2c6..e9bebe6f63 100644 --- a/tests/phpunit/tests/comment.php +++ b/tests/phpunit/tests/comment.php @@ -1265,10 +1265,10 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Number of exported comments. - $this->assertSame( 1, count( $actual['data'] ) ); + $this->assertCount( 1, $actual['data'] ); // Number of exported comment properties. - $this->assertSame( 8, count( $actual['data'][0]['data'] ) ); + $this->assertCount( 8, $actual['data'][0]['data'] ); // Exported group. $this->assertSame( 'comments', $actual['data'][0]['group_id'] ); @@ -1328,10 +1328,10 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Number of exported comments. - $this->assertSame( 1, count( $actual['data'] ) ); + $this->assertCount( 1, $actual['data'] ); // Number of exported comment properties. - $this->assertSame( 7, count( $actual['data'][0]['data'] ) ); + $this->assertCount( 7, $actual['data'][0]['data'] ); } /** @@ -1359,6 +1359,6 @@ class Tests_Comment extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Number of exported comments. - $this->assertSame( 0, count( $actual['data'] ) ); + $this->assertCount( 0, $actual['data'] ); } } diff --git a/tests/phpunit/tests/comment/getCommentExcerpt.php b/tests/phpunit/tests/comment/getCommentExcerpt.php index 88c964a3ee..3338a859bf 100644 --- a/tests/phpunit/tests/comment/getCommentExcerpt.php +++ b/tests/phpunit/tests/comment/getCommentExcerpt.php @@ -16,7 +16,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco $excerpt = get_comment_excerpt( $comment_id ); - $this->assertSame( 20, count( explode( ' ', $excerpt ) ) ); + $this->assertCount( 20, explode( ' ', $excerpt ) ); } public function test_get_comment_excerpt_filtered() { @@ -30,7 +30,7 @@ Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket baco $excerpt = get_comment_excerpt( $comment_id ); - $this->assertSame( 10, count( explode( ' ', $excerpt ) ) ); + $this->assertCount( 10, explode( ' ', $excerpt ) ); } public function _filter_comment_excerpt_length() { diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 8b5a523a40..9366164e70 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -1291,7 +1291,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { self::factory()->comment->create_post_comments( $post_id, $limit ); $comments = get_comments( array( 'post_id' => $post_id ) ); - $this->assertSame( $limit, count( $comments ) ); + $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { $this->assertEquals( $post_id, $comment->comment_post_ID ); } @@ -1300,7 +1300,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { self::factory()->comment->create_post_comments( $post_id2, $limit ); $comments = get_comments( array( 'post_id' => $post_id2 ) ); - $this->assertSame( $limit, count( $comments ) ); + $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { $this->assertEquals( $post_id2, $comment->comment_post_ID ); } @@ -1309,7 +1309,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '0' ) ); $comments = get_comments( array( 'post_id' => $post_id3 ) ); - $this->assertSame( $limit, count( $comments ) ); + $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { $this->assertEquals( $post_id3, $comment->comment_post_ID ); } @@ -1320,7 +1320,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'status' => 'hold', ) ); - $this->assertSame( $limit, count( $comments ) ); + $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { $this->assertEquals( $post_id3, $comment->comment_post_ID ); } @@ -1331,11 +1331,11 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'status' => 'approve', ) ); - $this->assertSame( 0, count( $comments ) ); + $this->assertCount( 0, $comments ); self::factory()->comment->create_post_comments( $post_id3, $limit, array( 'comment_approved' => '1' ) ); $comments = get_comments( array( 'post_id' => $post_id3 ) ); - $this->assertSame( $limit * 2, count( $comments ) ); + $this->assertCount( $limit * 2, $comments ); foreach ( $comments as $comment ) { $this->assertEquals( $post_id3, $comment->comment_post_ID ); } @@ -1362,7 +1362,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'orderby' => array( 'key' ), ) ); - $this->assertSame( 2, count( $comments ) ); + $this->assertCount( 2, $comments ); $this->assertEquals( $comment_id2, $comments[0]->comment_ID ); $this->assertEquals( $comment_id, $comments[1]->comment_ID ); @@ -1372,7 +1372,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'orderby' => array( 'meta_value' ), ) ); - $this->assertSame( 2, count( $comments ) ); + $this->assertCount( 2, $comments ); $this->assertEquals( $comment_id2, $comments[0]->comment_ID ); $this->assertEquals( $comment_id, $comments[1]->comment_ID ); @@ -1383,7 +1383,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'order' => 'ASC', ) ); - $this->assertSame( 2, count( $comments ) ); + $this->assertCount( 2, $comments ); $this->assertEquals( $comment_id, $comments[0]->comment_ID ); $this->assertEquals( $comment_id2, $comments[1]->comment_ID ); @@ -1394,7 +1394,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'order' => 'ASC', ) ); - $this->assertSame( 2, count( $comments ) ); + $this->assertCount( 2, $comments ); $this->assertEquals( $comment_id, $comments[0]->comment_ID ); $this->assertEquals( $comment_id2, $comments[1]->comment_ID ); @@ -1422,7 +1422,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'orderby' => array( 'key' ), ) ); - $this->assertSame( 1, count( $comments ) ); + $this->assertCount( 1, $comments ); $comments = get_comments( array( @@ -1430,7 +1430,7 @@ class Tests_Comment_Query extends WP_UnitTestCase { 'orderby' => array( 'meta_value' ), ) ); - $this->assertSame( 1, count( $comments ) ); + $this->assertCount( 1, $comments ); } /** diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php index 7d8af32cb5..1abd298397 100644 --- a/tests/phpunit/tests/feed/rss2.php +++ b/tests/phpunit/tests/feed/rss2.php @@ -106,7 +106,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one child element. - $this->assertSame( 1, count( $rss ) ); + $this->assertCount( 1, $rss ); $this->assertSame( '2.0', $rss[0]['attributes']['version'] ); $this->assertSame( 'http://purl.org/rss/1.0/modules/content/', $rss[0]['attributes']['xmlns:content'] ); @@ -114,7 +114,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $this->assertSame( 'http://purl.org/dc/elements/1.1/', $rss[0]['attributes']['xmlns:dc'] ); // RSS should have exactly one child element (channel). - $this->assertSame( 1, count( $rss[0]['child'] ) ); + $this->assertCount( 1, $rss[0]['child'] ); } /** @@ -320,7 +320,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one child element. - $this->assertSame( 1, count( $rss ) ); + $this->assertCount( 1, $rss ); } /* @@ -348,7 +348,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one child element. - $this->assertSame( 1, count( $rss ) ); + $this->assertCount( 1, $rss ); } /* @@ -381,7 +381,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one child element. - $this->assertSame( 1, count( $rss ) ); + $this->assertCount( 1, $rss ); } /* @@ -409,7 +409,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one child element. - $this->assertSame( 1, count( $rss ) ); + $this->assertCount( 1, $rss ); } /* @@ -437,7 +437,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one child element. - $this->assertSame( 1, count( $rss ) ); + $this->assertCount( 1, $rss ); } /* @@ -465,7 +465,7 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { $rss = xml_find( $xml, 'rss' ); // There should only be one child element. - $this->assertSame( 1, count( $rss ) ); + $this->assertCount( 1, $rss ); } /** diff --git a/tests/phpunit/tests/functions/wpListFilter.php b/tests/phpunit/tests/functions/wpListFilter.php index 64abe90c44..d86417cf02 100644 --- a/tests/phpunit/tests/functions/wpListFilter.php +++ b/tests/phpunit/tests/functions/wpListFilter.php @@ -51,7 +51,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'AND' ); - $this->assertSame( 2, count( $list ) ); + $this->assertCount( 2, $list ); $this->assertArrayHasKey( 'foo', $list ); $this->assertArrayHasKey( 'bar', $list ); } @@ -65,7 +65,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'OR' ); - $this->assertSame( 3, count( $list ) ); + $this->assertCount( 3, $list ); $this->assertArrayHasKey( 'foo', $list ); $this->assertArrayHasKey( 'bar', $list ); $this->assertArrayHasKey( 'baz', $list ); @@ -80,7 +80,7 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'NOT' ); - $this->assertSame( 1, count( $list ) ); + $this->assertCount( 1, $list ); $this->assertArrayHasKey( 'baz', $list ); } @@ -288,13 +288,13 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { function test_filter_object_list_nested_array_and() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND' ); - $this->assertSame( 1, count( $list ) ); + $this->assertCount( 1, $list ); $this->assertArrayHasKey( 'baz', $list ); } function test_filter_object_list_nested_array_not() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'red' ) ), 'NOT' ); - $this->assertSame( 2, count( $list ) ); + $this->assertCount( 2, $list ); $this->assertArrayHasKey( 'bar', $list ); $this->assertArrayHasKey( 'baz', $list ); } @@ -308,14 +308,14 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase { ), 'OR' ); - $this->assertSame( 2, count( $list ) ); + $this->assertCount( 2, $list ); $this->assertArrayHasKey( 'foo', $list ); $this->assertArrayHasKey( 'baz', $list ); } function test_filter_object_list_nested_array_or_singular() { $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'OR' ); - $this->assertSame( 1, count( $list ) ); + $this->assertCount( 1, $list ); $this->assertArrayHasKey( 'baz', $list ); } diff --git a/tests/phpunit/tests/import/import.php b/tests/phpunit/tests/import/import.php index 87ababf7a6..b3e2214f68 100644 --- a/tests/phpunit/tests/import/import.php +++ b/tests/phpunit/tests/import/import.php @@ -85,7 +85,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { 'orderby' => 'ID', ) ); - $this->assertSame( 11, count( $posts ) ); + $this->assertCount( 11, $posts ); $post = $posts[0]; $this->assertSame( 'Many Categories', $post->post_title ); @@ -95,7 +95,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertSame( 'publish', $post->post_status ); $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertSame( 27, count( $cats ) ); + $this->assertCount( 27, $cats ); $post = $posts[1]; $this->assertSame( 'Non-standard post format', $post->post_title ); @@ -105,7 +105,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertSame( 'publish', $post->post_status ); $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertSame( 1, count( $cats ) ); + $this->assertCount( 1, $cats ); $this->assertTrue( has_post_format( 'aside', $post->ID ) ); $post = $posts[2]; @@ -116,7 +116,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertSame( 'publish', $post->post_status ); $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) ); - $this->assertSame( 1, count( $cats ) ); + $this->assertCount( 1, $cats ); $this->assertSame( 'foo', $cats[0]->slug ); $post = $posts[3]; @@ -127,7 +127,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertSame( 'publish', $post->post_status ); $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) ); - $this->assertSame( 1, count( $cats ) ); + $this->assertCount( 1, $cats ); $this->assertSame( 'foo-bar', $cats[0]->slug ); $post = $posts[4]; @@ -138,9 +138,9 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertSame( 'private', $post->post_status ); $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertSame( 1, count( $cats ) ); + $this->assertCount( 1, $cats ); $tags = wp_get_post_tags( $post->ID ); - $this->assertSame( 3, count( $tags ) ); + $this->assertCount( 3, $tags ); $this->assertSame( 'tag1', $tags[0]->slug ); $this->assertSame( 'tag2', $tags[1]->slug ); $this->assertSame( 'tag3', $tags[2]->slug ); @@ -198,7 +198,7 @@ class Tests_Import_Import extends WP_Import_UnitTestCase { $this->assertSame( 'publish', $post->post_status ); $this->assertSame( 0, $post->post_parent ); $cats = wp_get_post_categories( $post->ID ); - $this->assertSame( 1, count( $cats ) ); + $this->assertCount( 1, $cats ); } function test_double_import() { diff --git a/tests/phpunit/tests/import/parser.php b/tests/phpunit/tests/import/parser.php index c7ceec6d9e..8142ef6a18 100644 --- a/tests/phpunit/tests/import/parser.php +++ b/tests/phpunit/tests/import/parser.php @@ -106,9 +106,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $message ); - $this->assertSame( 2, count( $result['posts'] ), $message ); - $this->assertSame( 19, count( $result['posts'][0] ), $message ); - $this->assertSame( 18, count( $result['posts'][1] ), $message ); + $this->assertCount( 2, $result['posts'], $message ); + $this->assertCount( 19, $result['posts'][0], $message ); + $this->assertCount( 18, $result['posts'][1], $message ); $this->assertEquals( array( array( @@ -160,9 +160,9 @@ class Tests_Import_Parser extends WP_Import_UnitTestCase { $this->assertSame( $result['tags'][0]['tag_slug'], 'chicken', $message ); $this->assertSame( $result['tags'][0]['tag_name'], 'chicken', $message ); - $this->assertSame( 6, count( $result['posts'] ), $message ); - $this->assertSame( 19, count( $result['posts'][0] ), $message ); - $this->assertSame( 18, count( $result['posts'][1] ), $message ); + $this->assertCount( 6, $result['posts'], $message ); + $this->assertCount( 19, $result['posts'][0], $message ); + $this->assertCount( 18, $result['posts'][1], $message ); $this->assertEquals( array( diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php index 9ea6b5817b..72cc004a1c 100644 --- a/tests/phpunit/tests/meta.php +++ b/tests/phpunit/tests/meta.php @@ -100,7 +100,7 @@ class Tests_Meta extends WP_UnitTestCase { $this->updated_mids = array(); foreach ( $found as $action => $mids ) { - $this->assertSame( 2, count( $mids ) ); + $this->assertCount( 2, $mids ); } } @@ -137,7 +137,7 @@ class Tests_Meta extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $u ) ); + $this->assertCount( 1, $u ); // User found is not locally defined author (it's the admin). $this->assertNotEquals( $this->author->user_login, $u[0]->user_login ); diff --git a/tests/phpunit/tests/multisite/networkQuery.php b/tests/phpunit/tests/multisite/networkQuery.php index fe82374a02..c8cc34d667 100644 --- a/tests/phpunit/tests/multisite/networkQuery.php +++ b/tests/phpunit/tests/multisite/networkQuery.php @@ -70,7 +70,7 @@ if ( is_multisite() ) : ) ); - $this->assertSame( 3, count( $found ) ); + $this->assertCount( 3, $found ); } public function test_wp_network_query_by_network__in_with_order() { diff --git a/tests/phpunit/tests/multisite/siteQuery.php b/tests/phpunit/tests/multisite/siteQuery.php index ef639f680b..34e8de9020 100644 --- a/tests/phpunit/tests/multisite/siteQuery.php +++ b/tests/phpunit/tests/multisite/siteQuery.php @@ -135,7 +135,7 @@ if ( is_multisite() ) : ) ); - $this->assertSame( 3, count( $found ) ); + $this->assertCount( 3, $found ); } public function test_wp_site_query_by_site__in_with_single_id() { diff --git a/tests/phpunit/tests/pomo/mo.php b/tests/phpunit/tests/pomo/mo.php index 5dd9956f9f..8539e5e431 100644 --- a/tests/phpunit/tests/pomo/mo.php +++ b/tests/phpunit/tests/pomo/mo.php @@ -15,7 +15,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { ), $mo->headers ); - $this->assertSame( 2, count( $mo->entries ) ); + $this->assertCount( 2, $mo->entries ); $this->assertSame( array( 'dyado' ), $mo->entries['baba']->translations ); $this->assertSame( array( 'yes' ), $mo->entries["kuku\nruku"]->translations ); } @@ -23,7 +23,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { function test_mo_plural() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/plural.mo' ); - $this->assertSame( 1, count( $mo->entries ) ); + $this->assertCount( 1, $mo->entries ); $this->assertSame( array( 'oney dragoney', 'twoey dragoney', 'manyey dragoney', 'manyeyey dragoney', 'manyeyeyey dragoney' ), $mo->entries['one dragon']->translations ); $this->assertSame( 'oney dragoney', $mo->translate_plural( 'one dragon', '%d dragons', 1 ) ); @@ -49,7 +49,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { function test_mo_context() { $mo = new MO(); $mo->import_from_file( DIR_TESTDATA . '/pomo/context.mo' ); - $this->assertSame( 2, count( $mo->entries ) ); + $this->assertCount( 2, $mo->entries ); $plural_entry = new Translation_Entry( array( 'singular' => 'one dragon', @@ -81,7 +81,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { $guest->add_entry( new Translation_Entry( array( 'singular' => 'green' ) ) ); $guest->add_entry( new Translation_Entry( array( 'singular' => 'red' ) ) ); $host->merge_with( $guest ); - $this->assertSame( 3, count( $host->entries ) ); + $this->assertCount( 3, $host->entries ); $this->assertSame( array(), array_diff( array( 'pink', 'green', 'red' ), array_keys( $host->entries ) ) ); } @@ -159,7 +159,7 @@ class Tests_POMO_MO extends WP_UnitTestCase { $again = new MO(); $again->import_from_file( $temp_fn ); - $this->assertSame( 0, count( $again->entries ) ); + $this->assertCount( 0, $again->entries ); } function test_nplurals_with_backslashn() { diff --git a/tests/phpunit/tests/pomo/po.php b/tests/phpunit/tests/pomo/po.php index 028c9ece9a..8b81ce7e9d 100644 --- a/tests/phpunit/tests/pomo/po.php +++ b/tests/phpunit/tests/pomo/po.php @@ -317,7 +317,7 @@ msgstr[2] "бабаяга"', function test_import_from_file_with_windows_line_endings_should_work_as_with_unix_line_endings() { $po = new PO(); $this->assertTrue( $po->import_from_file( DIR_TESTDATA . '/pomo/windows-line-endings.po' ) ); - $this->assertSame( 1, count( $po->entries ) ); + $this->assertCount( 1, $po->entries ); } // TODO: Add tests for bad files. diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 154997c1bf..65dd4ae783 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -98,12 +98,12 @@ class Tests_Post extends WP_UnitTestCase { update_object_term_cache( $id, $post_type ); $tcache = wp_cache_get( $id, 'post_tag_relationships' ); $this->assertIsArray( $tcache ); - $this->assertSame( 2, count( $tcache ) ); + $this->assertCount( 2, $tcache ); $tcache = wp_cache_get( $id, 'ctax_relationships' ); if ( 'cpt' === $post_type ) { $this->assertIsArray( $tcache ); - $this->assertSame( 2, count( $tcache ) ); + $this->assertCount( 2, $tcache ); } else { $this->assertFalse( $tcache ); } @@ -917,7 +917,7 @@ class Tests_Post extends WP_UnitTestCase { ); preg_match_all( '|href="([^"]+)"|', $wp_tag_cloud, $matches ); - $this->assertSame( 1, count( $matches[1] ) ); + $this->assertCount( 1, $matches[1] ); $terms = get_terms( $tax ); $term = reset( $terms ); diff --git a/tests/phpunit/tests/post/formats.php b/tests/phpunit/tests/post/formats.php index 5d462bf776..ac7ca3cf96 100644 --- a/tests/phpunit/tests/post/formats.php +++ b/tests/phpunit/tests/post/formats.php @@ -13,7 +13,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 1, count( $result ) ); + $this->assertCount( 1, $result ); $format = get_post_format( $post_id ); $this->assertSame( 'aside', $format ); @@ -21,12 +21,12 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); $result = set_post_format( $post_id, '' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); } /** @@ -41,7 +41,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 1, count( $result ) ); + $this->assertCount( 1, $result ); // The format can be set but not retrieved until it is registered. $format = get_post_format( $post_id ); $this->assertFalse( $format ); @@ -54,12 +54,12 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); $result = set_post_format( $post_id, '' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); remove_post_type_support( 'page', 'post-formats' ); } @@ -73,13 +73,13 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 1, count( $result ) ); + $this->assertCount( 1, $result ); $this->assertTrue( has_post_format( 'aside', $post_id ) ); $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); // Standard is a special case. It shows as false when set. $this->assertFalse( has_post_format( 'standard', $post_id ) ); diff --git a/tests/phpunit/tests/post/getPages.php b/tests/phpunit/tests/post/getPages.php index 771de856b7..94eb7fbdc4 100644 --- a/tests/phpunit/tests/post/getPages.php +++ b/tests/phpunit/tests/post/getPages.php @@ -16,7 +16,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { $this->assertFalse( wp_cache_get( 'last_changed', 'posts' ) ); $pages = get_pages(); - $this->assertSame( 3, count( $pages ) ); + $this->assertCount( 3, $pages ); $time1 = wp_cache_get( 'last_changed', 'posts' ); $this->assertNotEmpty( $time1 ); $num_queries = $wpdb->num_queries; @@ -26,7 +26,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { // Again. num_queries and last_changed should remain the same. $pages = get_pages(); - $this->assertSame( 3, count( $pages ) ); + $this->assertCount( 3, $pages ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); foreach ( $pages as $page ) { @@ -36,7 +36,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { // Again with different args. last_changed should not increment because of // different args to get_pages(). num_queries should bump by 1. $pages = get_pages( array( 'number' => 2 ) ); - $this->assertSame( 2, count( $pages ) ); + $this->assertCount( 2, $pages ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); foreach ( $pages as $page ) { @@ -47,7 +47,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { // Again. num_queries and last_changed should remain the same. $pages = get_pages( array( 'number' => 2 ) ); - $this->assertSame( 2, count( $pages ) ); + $this->assertCount( 2, $pages ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); foreach ( $pages as $page ) { @@ -56,7 +56,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { // Do the first query again. The interim queries should not affect it. $pages = get_pages(); - $this->assertSame( 3, count( $pages ) ); + $this->assertCount( 3, $pages ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); foreach ( $pages as $page ) { @@ -71,7 +71,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { // last_changed bumped so num_queries should increment. $pages = get_pages( array( 'number' => 2 ) ); - $this->assertSame( 2, count( $pages ) ); + $this->assertCount( 2, $pages ); $this->assertSame( $time2, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); foreach ( $pages as $page ) { @@ -91,7 +91,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { // num_queries should bump after wp_delete_post() bumps last_changed. $pages = get_pages(); - $this->assertSame( 2, count( $pages ) ); + $this->assertCount( 2, $pages ); $this->assertSame( $last_changed, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); foreach ( $pages as $page ) { @@ -277,7 +277,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { ) ) ); - $this->assertSame( 3, count( get_pages( array( 'meta_key' => 'some-meta-key' ) ) ) ); + $this->assertCount( 3, get_pages( array( 'meta_key' => 'some-meta-key' ) ) ); } /** @@ -372,7 +372,7 @@ class Tests_Post_GetPages extends WP_UnitTestCase { preg_match_all( '#assertSame( 5, count( $matches[0] ) ); + $this->assertCount( 5, $matches[0] ); } /** diff --git a/tests/phpunit/tests/post/objects.php b/tests/phpunit/tests/post/objects.php index 6c2f213fab..4602b014c7 100644 --- a/tests/phpunit/tests/post/objects.php +++ b/tests/phpunit/tests/post/objects.php @@ -113,17 +113,17 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post = get_post( $post_id ); $this->assertIsArray( $post->post_category ); - $this->assertSame( 1, count( $post->post_category ) ); + $this->assertCount( 1, $post->post_category ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); $term1 = wp_insert_term( 'Foo', 'category' ); $term2 = wp_insert_term( 'Bar', 'category' ); $term3 = wp_insert_term( 'Baz', 'category' ); wp_set_post_categories( $post_id, array( $term1['term_id'], $term2['term_id'], $term3['term_id'] ) ); - $this->assertSame( 3, count( $post->post_category ) ); + $this->assertCount( 3, $post->post_category ); $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post->post_category ); $post = get_post( $post_id, ARRAY_A ); - $this->assertSame( 3, count( $post['post_category'] ) ); + $this->assertCount( 3, $post['post_category'] ); $this->assertSame( array( $term2['term_id'], $term3['term_id'], $term1['term_id'] ), $post['post_category'] ); } @@ -135,12 +135,12 @@ class Tests_Post_Objects extends WP_UnitTestCase { $this->assertEmpty( $post->tags_input ); wp_set_post_tags( $post_id, 'Foo, Bar, Baz' ); $this->assertIsArray( $post->tags_input ); - $this->assertSame( 3, count( $post->tags_input ) ); + $this->assertCount( 3, $post->tags_input ); $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post->tags_input ); $post = get_post( $post_id, ARRAY_A ); $this->assertIsArray( $post['tags_input'] ); - $this->assertSame( 3, count( $post['tags_input'] ) ); + $this->assertCount( 3, $post['tags_input'] ); $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post['tags_input'] ); } diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index df72bdbe25..686f77a293 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -96,7 +96,7 @@ class Tests_Post_Query extends WP_UnitTestCase { ); // Fourth post added in filter. - $this->assertSame( 4, count( $query->posts ) ); + $this->assertCount( 4, $query->posts ); $this->assertSame( 4, $query->post_count ); foreach ( $query->posts as $post ) { diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index db0283bb0d..00615623e3 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -349,7 +349,7 @@ class Tests_Post_Types extends WP_UnitTestCase { $this->assertTrue( unregister_post_type( 'foo' ) ); $this->assertNotContains( '%foo%', $wp_rewrite->rewritecode ); $this->assertNotContains( 'bar=', $wp_rewrite->queryreplace ); - $this->assertSame( --$count_before, count( $wp_rewrite->rewritereplace ) ); // Array was reduced by one value. + $this->assertCount( --$count_before, $wp_rewrite->rewritereplace ); // Array was reduced by one value. } /** @@ -461,7 +461,7 @@ class Tests_Post_Types extends WP_UnitTestCase { ); $this->assertArrayHasKey( 'future_foo', $wp_filter ); - $this->assertSame( 1, count( $wp_filter['future_foo']->callbacks ) ); + $this->assertCount( 1, $wp_filter['future_foo']->callbacks ); $this->assertTrue( unregister_post_type( 'foo' ) ); $this->assertArrayNotHasKey( 'future_foo', $wp_filter ); } @@ -481,7 +481,7 @@ class Tests_Post_Types extends WP_UnitTestCase { ); $this->assertArrayHasKey( 'add_meta_boxes_foo', $wp_filter ); - $this->assertSame( 1, count( $wp_filter['add_meta_boxes_foo']->callbacks ) ); + $this->assertCount( 1, $wp_filter['add_meta_boxes_foo']->callbacks ); $this->assertTrue( unregister_post_type( 'foo' ) ); $this->assertArrayNotHasKey( 'add_meta_boxes_foo', $wp_filter ); } diff --git a/tests/phpunit/tests/query/metaQuery.php b/tests/phpunit/tests/query/metaQuery.php index 5acec55d3f..9a26ce2d2a 100644 --- a/tests/phpunit/tests/query/metaQuery.php +++ b/tests/phpunit/tests/query/metaQuery.php @@ -696,7 +696,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 0, count( $query->posts ) ); + $this->assertCount( 0, $query->posts ); } /** @@ -1534,7 +1534,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $query = new WP_Query( $args ); - $this->assertSame( 2, count( $query->posts ) ); + $this->assertCount( 2, $query->posts ); foreach ( $query->posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1550,7 +1550,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $query = new WP_Query( $args ); - $this->assertSame( 3, count( $query->posts ) ); + $this->assertCount( 3, $query->posts ); foreach ( $query->posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1582,7 +1582,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 2, count( $posts ) ); + $this->assertCount( 2, $posts ); $posts = wp_list_pluck( $posts, 'ID' ); $this->assertSameSets( array( $post_id, $post_id3 ), $posts ); @@ -1594,7 +1594,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 2, count( $posts ) ); + $this->assertCount( 2, $posts ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1625,7 +1625,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { ); $posts = get_posts( $args ); - $this->assertSame( 2, count( $posts ) ); + $this->assertCount( 2, $posts ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1659,7 +1659,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { 'meta_value' => '0', ) ); - $this->assertSame( 1, count( $q->posts ) ); + $this->assertCount( 1, $q->posts ); foreach ( $q->posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1672,7 +1672,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { 'meta_value' => '0', ) ); - $this->assertSame( 2, count( $posts ) ); + $this->assertCount( 2, $posts ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1686,7 +1686,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { 'meta_value' => 0, ) ); - $this->assertSame( 2, count( $posts ) ); + $this->assertCount( 2, $posts ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1695,7 +1695,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { $this->assertSameSets( array( $post_id, $post_id5 ), $posts ); $posts = get_posts( array( 'meta_value' => 0 ) ); - $this->assertSame( 5, count( $posts ) ); + $this->assertCount( 5, $posts ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); @@ -1704,7 +1704,7 @@ class Tests_Query_MetaQuery extends WP_UnitTestCase { $this->assertSameSets( array( $post_id, $post_id3, $post_id4, $post_id5, $post_id6 ), $posts ); $posts = get_posts( array( 'meta_value' => '0' ) ); - $this->assertSame( 5, count( $posts ) ); + $this->assertCount( 5, $posts ); foreach ( $posts as $post ) { $this->assertInstanceOf( 'WP_Post', $post ); $this->assertSame( 'raw', $post->filter ); diff --git a/tests/phpunit/tests/query/taxQuery.php b/tests/phpunit/tests/query/taxQuery.php index 0fe8a3ee77..2ca00b605b 100644 --- a/tests/phpunit/tests/query/taxQuery.php +++ b/tests/phpunit/tests/query/taxQuery.php @@ -1025,7 +1025,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ); $posts = $query->get_posts(); - $this->assertSame( 0, count( $posts ) ); + $this->assertCount( 0, $posts ); } /** @@ -1060,7 +1060,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ); $posts = $query->get_posts(); - $this->assertSame( 0, count( $posts ) ); + $this->assertCount( 0, $posts ); } public function test_tax_query_include_children() { @@ -1112,7 +1112,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 4, count( $posts ) ); + $this->assertCount( 4, $posts ); $posts = get_posts( array( @@ -1130,7 +1130,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $posts ) ); + $this->assertCount( 1, $posts ); $posts = get_posts( array( @@ -1147,7 +1147,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 3, count( $posts ) ); + $this->assertCount( 3, $posts ); $posts = get_posts( array( @@ -1165,7 +1165,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $posts ) ); + $this->assertCount( 1, $posts ); $posts = get_posts( array( @@ -1182,7 +1182,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $posts ) ); + $this->assertCount( 1, $posts ); $posts = get_posts( array( @@ -1200,7 +1200,7 @@ class Tests_Query_TaxQuery extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $posts ) ); + $this->assertCount( 1, $posts ); } public function test_tax_query_taxonomy_with_attachments() { diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index 195445aa44..f8773358e6 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -415,27 +415,27 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control // All attachments. $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $response = rest_get_server()->dispatch( $request ); - $this->assertSame( 2, count( $response->get_data() ) ); + $this->assertCount( 2, $response->get_data() ); $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); // Attachments without a parent. $request->set_param( 'parent', 0 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $attachment_id2, $data[0]['id'] ); // Attachments with parent=post_id. $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $request->set_param( 'parent', $post_id ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $attachment_id, $data[0]['id'] ); // Attachments with invalid parent. $request = new WP_REST_Request( 'GET', '/wp/v2/media' ); $request->set_param( 'parent', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 0, count( $data ) ); + $this->assertCount( 0, $data ); } public function test_get_items_invalid_status_param_is_error_response() { @@ -509,7 +509,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $ids = array( $data[0]['id'], $data[1]['id'], @@ -1465,7 +1465,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 27, count( $properties ) ); + $this->assertCount( 27, $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'alt_text', $properties ); $this->assertArrayHasKey( 'caption', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php index 0984bd3f83..39b7836b3e 100644 --- a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php +++ b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php @@ -286,7 +286,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 13, count( $properties ) ); + $this->assertCount( 13, $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'content', $properties ); $this->assertArrayHasKey( 'date', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-block-type-controller.php b/tests/phpunit/tests/rest-api/rest-block-type-controller.php index 3958c9bd19..38c0bfe2cd 100644 --- a/tests/phpunit/tests/rest-api/rest-block-type-controller.php +++ b/tests/phpunit/tests/rest-api/rest-block-type-controller.php @@ -341,7 +341,7 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $this->assertSame( $block_type, $data['name'] ); $this->assertArrayHasKey( 'variations', $data ); - $this->assertSame( 1, count( $data['variations'] ) ); + $this->assertCount( 1, $data['variations'] ); $variation = $data['variations'][0]; $this->assertSame( 'variation title', $variation['title'] ); $this->assertSame( 'variation description', $variation['description'] ); diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index 35ff944125..fb6d291d57 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -183,7 +183,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'hide_empty', true ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( 'Season 5', $data[0]['name'] ); $this->assertSame( 'The Be Sharps', $data[1]['name'] ); @@ -191,7 +191,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'hide_empty', 'false' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( $total_categories, count( $data ) ); + $this->assertCount( $total_categories, $data ); } public function test_get_items_parent_zero_arg() { @@ -291,14 +291,14 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id2, $data[0]['id'] ); } @@ -339,7 +339,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Uncategorized', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); @@ -349,7 +349,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( 'Apple', $data[0]['name'] ); } @@ -439,7 +439,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 3, count( $data ) ); + $this->assertCount( 3, $data ); // Check ordered by name by default. $names = wp_list_pluck( $data, 'name' ); @@ -457,7 +457,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 3, count( $data ) ); + $this->assertCount( 3, $data ); $names = wp_list_pluck( $data, 'name' ); $this->assertSame( array( 'Image', 'Marvel', 'DC' ), $names, 'Terms should be ordered by description' ); @@ -467,7 +467,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 3, count( $data ) ); + $this->assertCount( 3, $data ); $names = wp_list_pluck( $data, 'name' ); $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names, 'Terms should be reverse-ordered by description' ); } @@ -482,7 +482,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 3, count( $data ) ); + $this->assertCount( 3, $data ); $names = wp_list_pluck( $data, 'name' ); $this->assertSame( array( 'DC', 'Marvel', 'Image' ), $names ); } @@ -518,7 +518,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( 'Cape', $data[0]['name'] ); } @@ -535,7 +535,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Apple', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/categories' ); @@ -543,7 +543,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 0, count( $data ) ); + $this->assertCount( 0, $data ); } public function test_get_items_slug_arg() { @@ -555,7 +555,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Apple', $data[0]['name'] ); } @@ -572,7 +572,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $request->set_param( 'parent', $category1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Child', $data[0]['name'] ); } @@ -1130,7 +1130,7 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 9, count( $properties ) ); + $this->assertCount( 9, $properties ); $this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'count', $properties ); $this->assertArrayHasKey( 'description', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 3c1b1a2f2a..bd3283a373 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -488,14 +488,14 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'orderby' should error. @@ -3156,7 +3156,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 17, count( $properties ) ); + $this->assertCount( 17, $properties ); $this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'author_avatar_urls', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php index 6c524a10c2..411b39061f 100644 --- a/tests/phpunit/tests/rest-api/rest-pages-controller.php +++ b/tests/phpunit/tests/rest-api/rest-pages-controller.php @@ -109,7 +109,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $id1, $data[0]['id'] ); } @@ -132,13 +132,13 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); // Filter to parent. $request->set_param( 'parent', $id1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'parent' should error. @@ -179,13 +179,13 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 4, count( $data ) ); + $this->assertCount( 4, $data ); // Filter to parents. $request->set_param( 'parent', array( $id1, $id3 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSameSets( array( $id2, $id4 ), wp_list_pluck( $data, 'id' ) ); } @@ -208,13 +208,13 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/pages' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); // Filter to parent. $request->set_param( 'parent_exclude', $id1 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $id1, $data[0]['id'] ); // Invalid 'parent_exclude' should error. @@ -558,7 +558,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $this->assertSame( 2, $headers['X-WP-TotalPages'] ); $all_data = $response->get_data(); - $this->assertSame( 4, count( $all_data ) ); + $this->assertCount( 4, $all_data ); foreach ( $all_data as $post ) { $this->assertSame( 'page', $post['type'] ); } @@ -737,7 +737,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 24, count( $properties ) ); + $this->assertCount( 24, $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'comment_status', $properties ); $this->assertArrayHasKey( 'content', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php index 76ff41fe6b..273c4e3916 100644 --- a/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-statuses-controller.php @@ -38,7 +38,7 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $data = $response->get_data(); $statuses = get_post_stati( array( 'public' => true ), 'objects' ); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'publish', $data['publish']['slug'] ); } @@ -50,7 +50,7 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 6, count( $data ) ); + $this->assertCount( 6, $data ); $this->assertSameSets( array( 'publish', @@ -153,7 +153,7 @@ class WP_Test_REST_Post_Statuses_Controller extends WP_Test_REST_Controller_Test $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 8, count( $properties ) ); + $this->assertCount( 8, $properties ); $this->assertArrayHasKey( 'name', $properties ); $this->assertArrayHasKey( 'private', $properties ); $this->assertArrayHasKey( 'protected', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-post-types-controller.php b/tests/phpunit/tests/rest-api/rest-post-types-controller.php index bc99650c25..2a30c5e520 100644 --- a/tests/phpunit/tests/rest-api/rest-post-types-controller.php +++ b/tests/phpunit/tests/rest-api/rest-post-types-controller.php @@ -144,7 +144,7 @@ class WP_Test_REST_Post_Types_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 10, count( $properties ) ); + $this->assertCount( 10, $properties ); $this->assertArrayHasKey( 'capabilities', $properties ); $this->assertArrayHasKey( 'description', $properties ); $this->assertArrayHasKey( 'hierarchical', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index b167e4a629..3d94ea007f 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -268,7 +268,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'per_page', self::$per_page ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); - $this->assertSame( $total_posts, count( $response->get_data() ) ); + $this->assertCount( $total_posts, $response->get_data() ); // Limit to editor and author. $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); @@ -276,7 +276,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSameSets( array( self::$editor_id, self::$author_id ), wp_list_pluck( $data, 'author' ) ); // Limit to editor. @@ -285,7 +285,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( self::$editor_id, $data[0]['author'] ); } @@ -300,7 +300,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'per_page', self::$per_page ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); - $this->assertSame( $total_posts, count( $response->get_data() ) ); + $this->assertCount( $total_posts, $response->get_data() ); // Exclude editor and author. $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); @@ -309,7 +309,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( $total_posts - 2, count( $data ) ); + $this->assertCount( $total_posts - 2, $data ); $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); $this->assertNotEquals( self::$author_id, $data[0]['author'] ); @@ -320,7 +320,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( $total_posts - 1, count( $data ) ); + $this->assertCount( $total_posts - 1, $data ); $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); $this->assertNotEquals( self::$editor_id, $data[1]['author'] ); @@ -351,7 +351,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'include', array( $id1, $id2 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id2, $data[0]['id'] ); $this->assertPostsOrderedBy( '{posts}.post_date DESC' ); @@ -359,7 +359,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id1, $data[0]['id'] ); $this->assertPostsOrderedBy( "FIELD({posts}.ID,$id1,$id2)" ); @@ -509,13 +509,13 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'per_page', self::$per_page ); $response = rest_get_server()->dispatch( $request ); - $this->assertSame( $total_posts, count( $response->get_data() ) ); + $this->assertCount( $total_posts, $response->get_data() ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'search', 'Search Result' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Search Result', $data[0]['title']['rendered'] ); } @@ -538,7 +538,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Apple', $data[0]['title']['rendered'] ); } @@ -567,7 +567,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $titles = array( $data[0]['title']['rendered'], $data[1]['title']['rendered'], @@ -601,7 +601,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $titles = array( $data[0]['title']['rendered'], $data[1]['title']['rendered'], @@ -620,7 +620,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'status', 'publish' ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); - $this->assertSame( self::$total_posts, count( $response->get_data() ) ); + $this->assertCount( self::$total_posts, $response->get_data() ); $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); $request->set_param( 'status', 'draft' ); @@ -633,7 +633,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $request->set_param( 'status', 'draft' ); $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); - $this->assertSame( 1, count( $response->get_data() ) ); + $this->assertCount( 1, $response->get_data() ); } public function test_get_items_multiple_statuses_string_query() { @@ -650,7 +650,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $statuses = array( $data[0]['status'], $data[1]['status'], @@ -673,7 +673,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $statuses = array( $data[0]['status'], $data[1]['status'], @@ -4167,7 +4167,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 26, count( $properties ) ); + $this->assertCount( 26, $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'comment_status', $properties ); $this->assertArrayHasKey( 'content', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-revisions-controller.php index 5bd08ec914..d3cbc6c478 100644 --- a/tests/phpunit/tests/rest-api/rest-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-revisions-controller.php @@ -328,7 +328,7 @@ class WP_Test_REST_Revisions_Controller extends WP_Test_REST_Controller_Testcase $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 12, count( $properties ) ); + $this->assertCount( 12, $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'content', $properties ); $this->assertArrayHasKey( 'date', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-search-controller.php b/tests/phpunit/tests/rest-api/rest-search-controller.php index 931cf8fb51..f6706b18ff 100644 --- a/tests/phpunit/tests/rest-api/rest-search-controller.php +++ b/tests/phpunit/tests/rest-api/rest-search-controller.php @@ -175,7 +175,7 @@ class WP_Test_REST_Search_Controller extends WP_Test_REST_Controller_Testcase { ); $this->assertSame( 200, $response->get_status() ); - $this->assertSame( 3, count( $response->get_data() ) ); + $this->assertCount( 3, $response->get_data() ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php index 83bb34517f..23f41acb7f 100644 --- a/tests/phpunit/tests/rest-api/rest-tags-controller.php +++ b/tests/phpunit/tests/rest-api/rest-tags-controller.php @@ -200,7 +200,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'hide_empty', true ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( 'Season 5', $data[0]['name'] ); $this->assertSame( 'The Be Sharps', $data[1]['name'] ); @@ -220,14 +220,14 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'include' should error. @@ -302,7 +302,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Zucchini', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); @@ -312,7 +312,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( 'Apple', $data[0]['name'] ); // Invalid 'orderby' should error. @@ -387,7 +387,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( 'DC', $data[0]['name'] ); // Invalid 'post' should error. @@ -474,7 +474,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( 'Cape', $data[0]['name'] ); } @@ -491,7 +491,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Apple', $data[0]['name'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/tags' ); @@ -499,7 +499,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 0, count( $data ) ); + $this->assertCount( 0, $data ); } public function test_get_items_slug_arg() { @@ -511,7 +511,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( 'Apple', $data[0]['name'] ); } @@ -1224,7 +1224,7 @@ class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 8, count( $properties ) ); + $this->assertCount( 8, $properties ); $this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'count', $properties ); $this->assertArrayHasKey( 'description', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php index e624c14dc1..acca692482 100644 --- a/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php +++ b/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php @@ -211,7 +211,7 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $this->assertSame( 'post', $types[0] ); $this->assertArrayHasKey( 1, $types ); $this->assertSame( 'attachment', $types[1] ); - $this->assertSame( 2, count( $types ) ); + $this->assertCount( 2, $types ); } public function test_get_item_schema() { @@ -219,7 +219,7 @@ class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcas $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 10, count( $properties ) ); + $this->assertCount( 10, $properties ); $this->assertArrayHasKey( 'capabilities', $properties ); $this->assertArrayHasKey( 'description', $properties ); $this->assertArrayHasKey( 'hierarchical', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php index a228a81319..13c941c67b 100644 --- a/tests/phpunit/tests/rest-api/rest-themes-controller.php +++ b/tests/phpunit/tests/rest-api/rest-themes-controller.php @@ -342,7 +342,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = self::perform_active_theme_request( 'OPTIONS' ); $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 15, count( $properties ) ); + $this->assertCount( 15, $properties ); $this->assertArrayHasKey( 'author', $properties ); $this->assertArrayHasKey( 'raw', $properties['author']['properties'] ); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 0ac38bba62..5f1d6df4cc 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -387,12 +387,12 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $response = rest_get_server()->dispatch( $request ); - $this->assertSame( 10, count( $response->get_data() ) ); + $this->assertCount( 10, $response->get_data() ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'per_page', 5 ); $response = rest_get_server()->dispatch( $request ); - $this->assertSame( 5, count( $response->get_data() ) ); + $this->assertCount( 5, $response->get_data() ); } public function test_get_items_page() { @@ -402,7 +402,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'per_page', 5 ); $request->set_param( 'page', 2 ); $response = rest_get_server()->dispatch( $request ); - $this->assertSame( 5, count( $response->get_data() ) ); + $this->assertCount( 5, $response->get_data() ); $prev_link = add_query_arg( array( 'per_page' => 5, @@ -598,14 +598,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'include', array( $id2, $id1 ) ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id1, $data[0]['id'] ); // 'orderby' => 'include'. $request->set_param( 'orderby', 'include' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 2, count( $data ) ); + $this->assertCount( 2, $data ); $this->assertSame( $id2, $data[0]['id'] ); // Invalid 'include' should error. @@ -618,7 +618,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { wp_set_current_user( 0 ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 0, count( $data ) ); + $this->assertCount( 0, $data ); } @@ -655,14 +655,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'search', 'yololololo' ); $response = rest_get_server()->dispatch( $request ); - $this->assertSame( 0, count( $response->get_data() ) ); + $this->assertCount( 0, $response->get_data() ); $yolo_id = $this->factory->user->create( array( 'display_name' => 'yololololo' ) ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'search', 'yololololo' ); $response = rest_get_server()->dispatch( $request ); - $this->assertSame( 1, count( $response->get_data() ) ); + $this->assertCount( 1, $response->get_data() ); // Default to wildcard search. $adam_id = $this->factory->user->create( array( @@ -675,7 +675,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'search', 'ada' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $adam_id, $data[0]['id'] ); } @@ -699,7 +699,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'slug', 'foo' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $id2, $data[0]['id'] ); } @@ -812,14 +812,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'roles', 'author,subscriber' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 3, count( $data ) ); + $this->assertCount( 3, $data ); $this->assertSame( $tango, $data[1]['id'] ); $this->assertSame( $yolo, $data[2]['id'] ); $request->set_param( 'roles', 'author' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $yolo, $data[0]['id'] ); wp_set_current_user( 0 ); @@ -849,14 +849,14 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $request->set_param( 'roles', 'ilovesteak,author' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 1, count( $data ) ); + $this->assertCount( 1, $data ); $this->assertSame( $lolz, $data[0]['id'] ); $request = new WP_REST_Request( 'GET', '/wp/v2/users' ); $request->set_param( 'roles', 'steakisgood' ); $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertSame( 0, count( $data ) ); + $this->assertCount( 0, $data ); $this->assertSame( array(), $data ); } @@ -2620,7 +2620,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 19, count( $properties ) ); + $this->assertCount( 19, $properties ); $this->assertArrayHasKey( 'avatar_urls', $properties ); $this->assertArrayHasKey( 'capabilities', $properties ); $this->assertArrayHasKey( 'description', $properties ); diff --git a/tests/phpunit/tests/rest-api/rest-widgets-controller.php b/tests/phpunit/tests/rest-api/rest-widgets-controller.php index 86d162f510..e455954c33 100644 --- a/tests/phpunit/tests/rest-api/rest-widgets-controller.php +++ b/tests/phpunit/tests/rest-api/rest-widgets-controller.php @@ -1450,7 +1450,7 @@ class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); $properties = $data['schema']['properties']; - $this->assertSame( 7, count( $properties ) ); + $this->assertCount( 7, $properties ); $this->assertArrayHasKey( 'id', $properties ); $this->assertArrayHasKey( 'id_base', $properties ); $this->assertArrayHasKey( 'sidebar', $properties ); diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 803419bf32..6ae814a7e7 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -862,7 +862,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { $this->assertTrue( unregister_taxonomy( 'foo' ) ); $this->assertNotContains( '%foo%', $wp_rewrite->rewritecode ); $this->assertNotContains( 'bar=', $wp_rewrite->queryreplace ); - $this->assertSame( --$count_before, count( $wp_rewrite->rewritereplace ) ); // Array was reduced by one value. + $this->assertCount( --$count_before, $wp_rewrite->rewritereplace ); // Array was reduced by one value. } /** @@ -891,7 +891,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_taxonomy( 'foo', 'post' ); $this->assertArrayHasKey( 'wp_ajax_add-foo', $wp_filter ); - $this->assertSame( 1, count( $wp_filter['wp_ajax_add-foo']->callbacks ) ); + $this->assertCount( 1, $wp_filter['wp_ajax_add-foo']->callbacks ); $this->assertTrue( unregister_taxonomy( 'foo' ) ); $this->assertArrayNotHasKey( 'wp_ajax_add-foo', $wp_filter ); } diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 2525a8c53f..ce496df353 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -101,19 +101,19 @@ class Tests_Term extends WP_UnitTestCase { $tags = self::factory()->tag->create_many( 5 ); $tt = wp_add_object_terms( $posts[0], $tags[1], 'post_tag' ); - $this->assertSame( 1, count( $tt ) ); + $this->assertCount( 1, $tt ); $this->assertSame( array( $tags[1] ), wp_get_object_terms( $posts[0], 'post_tag', array( 'fields' => 'ids' ) ) ); $three_tags = array( $tags[0], $tags[1], $tags[2] ); $tt = wp_add_object_terms( $posts[1], $three_tags, 'post_tag' ); - $this->assertSame( 3, count( $tt ) ); + $this->assertCount( 3, $tt ); $this->assertSame( $three_tags, wp_get_object_terms( $posts[1], 'post_tag', array( 'fields' => 'ids' ) ) ); $this->assertTrue( wp_remove_object_terms( $posts[0], $tags[1], 'post_tag' ) ); $this->assertFalse( wp_remove_object_terms( $posts[0], $tags[0], 'post_tag' ) ); $this->assertInstanceOf( 'WP_Error', wp_remove_object_terms( $posts[0], $tags[1], 'non_existing_taxonomy' ) ); $this->assertTrue( wp_remove_object_terms( $posts[1], $three_tags, 'post_tag' ) ); - $this->assertSame( 0, count( wp_get_object_terms( $posts[1], 'post_tag' ) ) ); + $this->assertCount( 0, wp_get_object_terms( $posts[1], 'post_tag' ) ); foreach ( $tags as $term_id ) { $this->assertTrue( wp_delete_term( $term_id, 'post_tag' ) ); @@ -177,7 +177,7 @@ class Tests_Term extends WP_UnitTestCase { $post = get_post( $post_id ); $this->assertIsArray( $post->post_category ); - $this->assertSame( 1, count( $post->post_category ) ); + $this->assertCount( 1, $post->post_category ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); $term1 = wp_insert_term( 'Foo', 'category' ); @@ -185,7 +185,7 @@ class Tests_Term extends WP_UnitTestCase { $term3 = wp_insert_term( 'Baz', 'category' ); wp_set_post_categories( $post_id, array( $term1['term_id'], $term2['term_id'] ) ); - $this->assertSame( 2, count( $post->post_category ) ); + $this->assertCount( 2, $post->post_category ); $this->assertSame( array( $term2['term_id'], $term1['term_id'] ), $post->post_category ); wp_set_post_categories( $post_id, $term3['term_id'], true ); @@ -200,11 +200,11 @@ class Tests_Term extends WP_UnitTestCase { $this->assertSame( array( $term2['term_id'], $term4['term_id'], $term1['term_id'] ), $post->post_category ); wp_set_post_categories( $post_id, array(), true ); - $this->assertSame( 1, count( $post->post_category ) ); + $this->assertCount( 1, $post->post_category ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); wp_set_post_categories( $post_id, array() ); - $this->assertSame( 1, count( $post->post_category ) ); + $this->assertCount( 1, $post->post_category ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); } diff --git a/tests/phpunit/tests/term/cache.php b/tests/phpunit/tests/term/cache.php index 07bbc5426a..19e011ff99 100644 --- a/tests/phpunit/tests/term/cache.php +++ b/tests/phpunit/tests/term/cache.php @@ -83,7 +83,7 @@ class Tests_Term_Cache extends WP_UnitTestCase { } $terms = get_terms( $tax, array( 'hide_empty' => false ) ); - $this->assertSame( $i, count( $terms ) ); + $this->assertCount( $i, $terms ); if ( $i > 1 ) { $hierarchy = _get_term_hierarchy( $tax ); $this->assertNotEmpty( $hierarchy ); diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index d42dd44099..ea16c6429b 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -115,7 +115,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // last_changed and num_queries should bump. $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); - $this->assertSame( 3, count( $terms ) ); + $this->assertCount( 3, $terms ); $time1 = wp_cache_get( 'last_changed', 'terms' ); $this->assertNotEmpty( $time1 ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -124,7 +124,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // Again. last_changed and num_queries should remain the same. $terms = get_terms( 'post_tag', array( 'update_term_meta_cache' => false ) ); - $this->assertSame( 3, count( $terms ) ); + $this->assertCount( 3, $terms ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); } @@ -144,7 +144,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // num_queries should bump, last_changed should remain the same. $terms = get_terms( 'post_tag', array( 'number' => 2 ) ); - $this->assertSame( 2, count( $terms ) ); + $this->assertCount( 2, $terms ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -152,7 +152,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // Again. last_changed and num_queries should remain the same. $terms = get_terms( 'post_tag', array( 'number' => 2 ) ); - $this->assertSame( 2, count( $terms ) ); + $this->assertCount( 2, $terms ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'terms' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); } @@ -179,7 +179,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // last_changed and num_queries should bump after a term is deleted. $terms = get_terms( 'post_tag' ); - $this->assertSame( 2, count( $terms ) ); + $this->assertCount( 2, $terms ); $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -187,7 +187,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { // Again. last_changed and num_queries should remain the same. $terms = get_terms( 'post_tag' ); - $this->assertSame( 2, count( $terms ) ); + $this->assertCount( 2, $terms ); $this->assertSame( $time2, wp_cache_get( 'last_changed', 'terms' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); @@ -617,7 +617,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'cache_domain' => $tax, ) ); - $this->assertSame( 2, count( $terms ) ); + $this->assertCount( 2, $terms ); $this->assertSame( wp_list_pluck( $terms, 'name' ), array( 'Cheese', 'Crackers' ) ); } @@ -660,7 +660,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'cache_domain' => $tax, ) ); - $this->assertSame( 1, count( $terms ) ); + $this->assertCount( 1, $terms ); $this->assertSame( array( 'Cheese' ), wp_list_pluck( $terms, 'name' ) ); _unregister_taxonomy( $tax ); @@ -696,7 +696,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'cache_domain' => $tax, ) ); - $this->assertSame( 1, count( $terms ) ); + $this->assertCount( 1, $terms ); $this->assertSame( array( 'term1' ), wp_list_pluck( $terms, 'name' ) ); _unregister_taxonomy( $tax ); @@ -716,7 +716,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { 'hide_empty' => false, ) ); - $this->assertSame( 1, count( $terms ) ); + $this->assertCount( 1, $terms ); } /** @@ -2308,7 +2308,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ); // Verify that there are no children. - $this->assertSame( 0, count( $terms ) ); + $this->assertCount( 0, $terms ); } /** @@ -2374,7 +2374,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ); // Verify that there are no children. - $this->assertSame( 0, count( $terms ) ); + $this->assertCount( 0, $terms ); } public function test_hierarchical_true_with_child_of_should_return_grandchildren() { @@ -2487,7 +2487,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { ); // 'hierarchical=false' means that descendants are not fetched. - $this->assertSame( 0, count( $terms ) ); + $this->assertCount( 0, $terms ); } /** diff --git a/tests/phpunit/tests/term/getTheTerms.php b/tests/phpunit/tests/term/getTheTerms.php index 4603790787..096993ecb1 100644 --- a/tests/phpunit/tests/term/getTheTerms.php +++ b/tests/phpunit/tests/term/getTheTerms.php @@ -22,7 +22,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { // Cache should be empty after a set. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertSame( 3, count( $tt_1 ) ); + $this->assertCount( 3, $tt_1 ); $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships' ) ); // wp_get_object_terms() does not prime the cache. @@ -43,7 +43,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { // Cache should be empty after a set. $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy ); - $this->assertSame( 2, count( $tt_2 ) ); + $this->assertCount( 2, $tt_2 ); $this->assertFalse( wp_cache_get( $post_id, $this->taxonomy . '_relationships' ) ); } diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index f821a67511..9d3350eab0 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -455,7 +455,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { $term_meta_id = add_term_meta( $t, 'foo', 'bar' ); $meta = has_term_meta( $t ); - $this->assertSame( 1, count( $meta ) ); + $this->assertCount( 1, $meta ); $expected = array( 'meta_key' => 'foo', diff --git a/tests/phpunit/tests/term/query.php b/tests/phpunit/tests/term/query.php index 425815cd17..6dbd2cb2f0 100644 --- a/tests/phpunit/tests/term/query.php +++ b/tests/phpunit/tests/term/query.php @@ -288,7 +288,7 @@ class Tests_Term_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $query->terms ) ); + $this->assertCount( 1, $query->terms ); $this->assertSame( $t, reset( $query->terms )->term_id ); } @@ -312,7 +312,7 @@ class Tests_Term_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 2, count( $query->terms ) ); + $this->assertCount( 2, $query->terms ); foreach ( $query->terms as $term ) { $this->assertSame( $t, $term->term_id ); } diff --git a/tests/phpunit/tests/term/taxQuery.php b/tests/phpunit/tests/term/taxQuery.php index 495a21ea5f..677ad15e3b 100644 --- a/tests/phpunit/tests/term/taxQuery.php +++ b/tests/phpunit/tests/term/taxQuery.php @@ -111,7 +111,7 @@ class Tests_Term_Tax_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $q->queries ) ); + $this->assertCount( 1, $q->queries ); } public function test_transform_query_terms_empty() { diff --git a/tests/phpunit/tests/term/wpGetObjectTerms.php b/tests/phpunit/tests/term/wpGetObjectTerms.php index 7e2aa0cd30..03e2301ecf 100644 --- a/tests/phpunit/tests/term/wpGetObjectTerms.php +++ b/tests/phpunit/tests/term/wpGetObjectTerms.php @@ -20,7 +20,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { // Set the initial terms. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertSame( 3, count( $tt_1 ) ); + $this->assertCount( 3, $tt_1 ); // Make sure they're correct. $terms = wp_get_object_terms( diff --git a/tests/phpunit/tests/term/wpSetObjectTerms.php b/tests/phpunit/tests/term/wpSetObjectTerms.php index 024d2e9449..1db10a651c 100644 --- a/tests/phpunit/tests/term/wpSetObjectTerms.php +++ b/tests/phpunit/tests/term/wpSetObjectTerms.php @@ -113,7 +113,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { foreach ( $ids as $id ) { $tt = wp_set_object_terms( $id, array_values( $term_id ), $this->taxonomy ); // Should return three term taxonomy IDs. - $this->assertSame( 3, count( $tt ) ); + $this->assertCount( 3, $tt ); } // Each term should be associated with every post. @@ -141,7 +141,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { foreach ( $ids as $id ) { $tt = wp_set_object_terms( $id, $terms, $this->taxonomy ); // Should return three term taxonomy IDs. - $this->assertSame( 3, count( $tt ) ); + $this->assertCount( 3, $tt ); // Remember which term has which term_id. for ( $i = 0; $i < 3; $i++ ) { $term = get_term_by( 'name', $terms[ $i ], $this->taxonomy ); @@ -268,7 +268,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // Set the initial terms. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertSame( 3, count( $tt_1 ) ); + $this->assertCount( 3, $tt_1 ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -283,7 +283,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // Change the terms. $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy ); - $this->assertSame( 2, count( $tt_2 ) ); + $this->assertCount( 2, $tt_2 ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -312,7 +312,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // Set the initial terms. $tt_1 = wp_set_object_terms( $post_id, $terms_1, $this->taxonomy ); - $this->assertSame( 3, count( $tt_1 ) ); + $this->assertCount( 3, $tt_1 ); // Make sure they're correct. $terms = wp_get_object_terms( @@ -327,7 +327,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { // Change the terms. $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy ); - $this->assertSame( 2, count( $tt_2 ) ); + $this->assertCount( 2, $tt_2 ); // Make sure they're correct. $terms = wp_get_object_terms( diff --git a/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php b/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php index 73c84c57bd..356e7f166f 100644 --- a/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php +++ b/tests/phpunit/tests/theme/wpThemeGetAllowedFilters.php @@ -21,7 +21,7 @@ if ( is_multisite() ) : WP_Theme::get_allowed( $blog_id ); remove_filter( 'network_allowed_themes', array( $this, 'filter_network_allowed_themes' ) ); - $this->assertSame( 2, count( $this->filter_network_allowed_themes_args ) ); + $this->assertCount( 2, $this->filter_network_allowed_themes_args ); $this->assertSame( $blog_id, $this->filter_network_allowed_themes_args[1] ); } diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index 0830385e02..9ff5a4749a 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -767,7 +767,7 @@ class Tests_User extends WP_UnitTestCase { $response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] ); $this->assertInstanceOf( 'WP_Error', $response['errors'] ); - $this->assertSame( 0, count( $response['errors']->get_error_codes() ) ); + $this->assertCount( 0, $response['errors']->get_error_codes() ); } function _illegal_user_logins_data() { @@ -1728,10 +1728,10 @@ class Tests_User extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Number of exported users. - $this->assertSame( 1, count( $actual['data'] ) ); + $this->assertCount( 1, $actual['data'] ); // Number of exported user properties. - $this->assertSame( 11, count( $actual['data'][0]['data'] ) ); + $this->assertCount( 11, $actual['data'][0]['data'] ); } /** @@ -1862,11 +1862,11 @@ class Tests_User extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Number of exported users. - $this->assertSame( 1, count( $actual['data'] ) ); + $this->assertCount( 1, $actual['data'] ); // Number of exported user properties (the 11 core properties, // plus 1 additional from the filter). - $this->assertSame( 12, count( $actual['data'][0]['data'] ) ); + $this->assertCount( 12, $actual['data'][0]['data'] ); // Check that the item added by the filter was retained. $this->assertSame( @@ -1894,11 +1894,11 @@ class Tests_User extends WP_UnitTestCase { $this->assertTrue( $actual['done'] ); // Number of exported users. - $this->assertSame( 1, count( $actual['data'] ) ); + $this->assertCount( 1, $actual['data'] ); // Number of exported user properties // (the 11 core properties, plus 1 additional from the filter). - $this->assertSame( 12, count( $actual['data'][0]['data'] ) ); + $this->assertCount( 12, $actual['data'][0]['data'] ); // Check that the duplicate 'name' => 'User ID' was stripped. $this->assertSame( diff --git a/tests/phpunit/tests/user/query.php b/tests/phpunit/tests/user/query.php index 6f8f6f0e73..41401d74ca 100644 --- a/tests/phpunit/tests/user/query.php +++ b/tests/phpunit/tests/user/query.php @@ -137,7 +137,7 @@ class Tests_User_Query extends WP_UnitTestCase { $users = $users->get_results(); // +1 for the default user created during installation. - $this->assertSame( 13, count( $users ) ); + $this->assertCount( 13, $users ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); } @@ -149,7 +149,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertSame( 13, count( $users ) ); + $this->assertCount( 13, $users ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); } @@ -502,7 +502,7 @@ class Tests_User_Query extends WP_UnitTestCase { // +1 for the default user created by the test suite. $users = new WP_User_Query( array( 'blog_id' => get_current_blog_id() ) ); $users = $users->get_results(); - $this->assertSame( 13, count( $users ) ); + $this->assertCount( 13, $users ); $users = new WP_User_Query( array( @@ -511,7 +511,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertSame( 10, count( $users ) ); + $this->assertCount( 10, $users ); $users = new WP_User_Query( array( @@ -520,7 +520,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertSame( 2, count( $users ) ); + $this->assertCount( 2, $users ); $users = new WP_User_Query( array( @@ -529,7 +529,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); $users = $users->get_results(); - $this->assertSame( 13, count( $users ) ); + $this->assertCount( 13, $users ); } /** @@ -1314,7 +1314,7 @@ class Tests_User_Query extends WP_UnitTestCase { $wp_user_search = new WP_User_Query( array( 'role' => 'subscriber' ) ); $users = $wp_user_search->get_results(); - $this->assertSame( 2, count( $users ) ); + $this->assertCount( 2, $users ); } /** @@ -1323,7 +1323,7 @@ class Tests_User_Query extends WP_UnitTestCase { public function test_get_multiple_roles_by_user_query() { $wp_user_search = new WP_User_Query( array( 'role__in' => array( 'subscriber', 'editor' ) ) ); $users = $wp_user_search->get_results(); - $this->assertSame( 5, count( $users ) ); + $this->assertCount( 5, $users ); } /** @@ -1336,7 +1336,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 2, count( $users ) ); + $this->assertCount( 2, $users ); } /** @@ -1372,7 +1372,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 2, count( $users ) ); + $this->assertCount( 2, $users ); } /** @@ -1392,7 +1392,7 @@ class Tests_User_Query extends WP_UnitTestCase { $users = new WP_User_Query( array( 'role' => array( 'subscriber', 'editor' ) ) ); $users = $users->get_results(); - $this->assertSame( 2, count( $users ) ); + $this->assertCount( 2, $users ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); @@ -1407,7 +1407,7 @@ class Tests_User_Query extends WP_UnitTestCase { $users = $users->get_results(); // +1 for the default user created during installation. - $this->assertSame( 8, count( $users ) ); + $this->assertCount( 8, $users ); foreach ( $users as $user ) { $this->assertInstanceOf( 'WP_User', $user ); } @@ -1436,7 +1436,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 2, count( $users ) ); + $this->assertCount( 2, $users ); } /** @@ -1482,7 +1482,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // Check results. - $this->assertSame( 1, count( $users ) ); + $this->assertCount( 1, $users ); $this->assertSame( self::$editor_ids[0], (int) $users[0]->ID ); } @@ -1497,7 +1497,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertSame( 11, count( $users ) ); + $this->assertCount( 11, $users ); $users = get_users( array( @@ -1506,7 +1506,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertSame( 10, count( $users ) ); + $this->assertCount( 10, $users ); } /** @@ -1524,7 +1524,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 5, count( $users ) ); + $this->assertCount( 5, $users ); $users = get_users( array( @@ -1533,7 +1533,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 3, count( $users ) ); + $this->assertCount( 3, $users ); } /** @@ -1550,7 +1550,7 @@ class Tests_User_Query extends WP_UnitTestCase { ) ); - $this->assertSame( 1, count( $users ) ); + $this->assertCount( 1, $users ); } /** @@ -1568,7 +1568,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertSame( 12, count( $users ) ); + $this->assertCount( 12, $users ); $users = get_users( array( @@ -1577,7 +1577,7 @@ class Tests_User_Query extends WP_UnitTestCase { ); // +1 for the default user created during installation. - $this->assertSame( 10, count( $users ) ); + $this->assertCount( 10, $users ); } /** diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index 9ea548055a..c3ddfca599 100644 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -156,7 +156,7 @@ class Tests_Widgets extends WP_UnitTestCase { } } - $this->assertSame( $num, count( $result ) ); + $this->assertCount( $num, $result ); } diff --git a/tests/phpunit/tests/wp.php b/tests/phpunit/tests/wp.php index cdb3f79525..3e80b303c8 100644 --- a/tests/phpunit/tests/wp.php +++ b/tests/phpunit/tests/wp.php @@ -21,7 +21,7 @@ class Tests_WP extends WP_UnitTestCase { $this->wp->add_query_var( 'test2' ); $this->wp->add_query_var( 'test' ); - $this->assertSame( $public_qv_count + 2, count( $this->wp->public_query_vars ) ); + $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 ) ); } @@ -33,6 +33,6 @@ class Tests_WP extends WP_UnitTestCase { $this->assertTrue( in_array( 'test', $this->wp->public_query_vars, true ) ); $this->wp->remove_query_var( 'test' ); - $this->assertSame( $public_qv_count, count( $this->wp->public_query_vars ) ); + $this->assertCount( $public_qv_count, $this->wp->public_query_vars ); } } diff --git a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php index c615a26b7d..3c04643032 100644 --- a/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php +++ b/tests/phpunit/tests/xmlrpc/mt/getRecentPostTitles.php @@ -26,7 +26,7 @@ class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) ); $this->assertNotIXRError( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); } function test_date() { diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php index 71bc3b92b7..e6b00e5e42 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php +++ b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php @@ -44,7 +44,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) ); $this->assertNotIXRError( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); } function test_valid_post() { diff --git a/tests/phpunit/tests/xmlrpc/wp/editPost.php b/tests/phpunit/tests/xmlrpc/wp/editPost.php index 4e502f4df5..389345a9b8 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/editPost.php @@ -442,7 +442,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $enclosure ); // Verify that there is only a single value in the array and that a duplicate is not present. - $this->assertSame( 1, count( get_post_meta( $post_id, 'enclosure' ) ) ); + $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 ) ); @@ -451,7 +451,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $this->myxmlrpcserver->add_enclosure_if_new( $post_id, $new_enclosure ); // Having added the new enclosure, 2 values are expected in the array. - $this->assertSame( 2, count( get_post_meta( $post_id, 'enclosure' ) ) ); + $this->assertCount( 2, get_post_meta( $post_id, 'enclosure' ) ); // 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"; diff --git a/tests/phpunit/tests/xmlrpc/wp/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php index 4a716dd336..b0bc92cd58 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -85,7 +85,7 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // When no fields are requested, only the IDs should be returned. - $this->assertSame( 1, count( $result ) ); + $this->assertCount( 1, $result ); $this->assertSame( array( 'post_id' ), array_keys( $result ) ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php index a72cbdcdae..4a2ddf6179 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php @@ -16,7 +16,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'subscriber', 'subscriber' ) ); $this->assertNotIXRError( $result ); $this->assertIsArray( $result ); - $this->assertSame( 0, count( $result ) ); + $this->assertCount( 0, $result ); } function test_capable_user() { diff --git a/tests/phpunit/tests/xmlrpc/wp/getPosts.php b/tests/phpunit/tests/xmlrpc/wp/getPosts.php index 92b54e7870..c7b49e25f0 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPosts.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPosts.php @@ -71,7 +71,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertSame( $num_posts, count( $results ) ); + $this->assertCount( $num_posts, $results ); // Page through results. $posts_found = array(); @@ -83,7 +83,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $filter['offset'] += $filter['number']; } while ( count( $presults ) > 0 ); // Verify that $post_ids matches $posts_found. - $this->assertSame( 0, count( array_diff( $post_ids, $posts_found ) ) ); + $this->assertCount( 0, array_diff( $post_ids, $posts_found ) ); // Add comments to some of the posts. foreach ( $post_ids as $key => $post_id ) { @@ -117,7 +117,7 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { ); $results3 = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter3 ) ); $this->assertNotIXRError( $results3 ); - $this->assertSame( 1, count( $results3 ) ); + $this->assertCount( 1, $results3 ); $this->assertEquals( $post->ID, $results3[0]['post_id'] ); _unregister_post_type( $cpt_name ); @@ -159,13 +159,13 @@ class Tests_XMLRPC_wp_getPosts extends WP_XMLRPC_UnitTestCase { $filter = array( 's' => 'Third' ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertSame( 0, count( $results ) ); + $this->assertCount( 0, $results ); // Search for one of them. $filter = array( 's' => 'First:' ); $results = $this->myxmlrpcserver->wp_getPosts( array( 1, 'editor', 'editor', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertSame( 1, count( $results ) ); + $this->assertCount( 1, $results ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php index b334235cf5..a677be39fc 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerms.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerms.php @@ -77,7 +77,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name ) ); $this->assertNotIXRError( $results ); - $this->assertSame( $num_terms, count( $results ) ); + $this->assertCount( $num_terms, $results ); foreach ( $results as $term ) { $this->assertSame( $tax_name, $term['taxonomy'] ); } @@ -86,20 +86,20 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $filter = array( 'number' => 5 ); $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); $this->assertNotIXRError( $results ); - $this->assertSame( 5, count( $results2 ) ); + $this->assertCount( 5, $results2 ); $this->assertSame( $results[1]['term_id'], $results2[1]['term_id'] ); // Check one of the terms. $filter['offset'] = 10; $results3 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); $this->assertNotIXRError( $results3 ); - $this->assertSame( $num_terms - 10, count( $results3 ) ); + $this->assertCount( $num_terms - 10, $results3 ); $this->assertSame( $results[11]['term_id'], $results3[1]['term_id'] ); // Test hide_empty (since none have been attached to posts yet, all should be hidden. $filter = array( 'hide_empty' => true ); $results4 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', $tax_name, $filter ) ); $this->assertNotIXRError( $results4 ); - $this->assertSame( 0, count( $results4 ) ); + $this->assertCount( 0, $results4 ); unset( $GLOBALS['wp_taxonomies'][ $tax_name ] ); } @@ -119,7 +119,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { ); $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertNotEquals( 0, count( $results ) ); + $this->assertNotCount( 0, $results ); foreach ( $results as $term ) { if ( $term['term_id'] === $cat1 ) { @@ -140,7 +140,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $filter = array( 'search' => $name ); $results = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); $this->assertNotIXRError( $results ); - $this->assertSame( 1, count( $results ) ); + $this->assertCount( 1, $results ); $this->assertSame( $name, $results[0]['name'] ); $this->assertEquals( $name_id, $results[0]['term_id'] ); @@ -148,7 +148,7 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $filter = array( 'search' => substr( $name, 0, 10 ) ); $results2 = $this->myxmlrpcserver->wp_getTerms( array( 1, 'editor', 'editor', 'category', $filter ) ); $this->assertNotIXRError( $results2 ); - $this->assertSame( 1, count( $results2 ) ); + $this->assertCount( 1, $results2 ); $this->assertSame( $name, $results2[0]['name'] ); $this->assertEquals( $name_id, $results2[0]['term_id'] ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php index 1e9466eb95..627facea5c 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php @@ -102,7 +102,7 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { } while ( count( $presults ) > 0 ); // Verify that $user_ids matches $users_found. - $this->assertSame( 0, count( array_diff( $user_ids, $users_found ) ) ); + $this->assertCount( 0, array_diff( $user_ids, $users_found ) ); } function test_order_filters() {