From 8fc144ab27470b3d47dcffe7d4eaecf9318e78ad Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 17 Feb 2024 16:32:37 +0000 Subject: [PATCH] Tests: Use `assertSame()` in `get_comment_pages_count()` tests. This ensures that not only the return values match the expected results, but also that their type is the same. Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable. Follow-up to [27055], [48937], [54402], [57244], [57648]. Props costdev. See #58683, #59655. git-svn-id: https://develop.svn.wordpress.org/trunk@57650 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/comment/getCommentsPagesCount.php | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/phpunit/tests/comment/getCommentsPagesCount.php b/tests/phpunit/tests/comment/getCommentsPagesCount.php index a3c815f8c4..146def6fd5 100644 --- a/tests/phpunit/tests/comment/getCommentsPagesCount.php +++ b/tests/phpunit/tests/comment/getCommentsPagesCount.php @@ -78,9 +78,9 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { self::factory()->comment->create_post_comments( $post->ID, 6, array( 'comment_parent' => $comments[0] ) ); $comments = get_comments( array( 'post_id' => $post->ID ) ); - $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) ); - $this->assertEquals( 2, get_comment_pages_count( $comments, 10, true ) ); - $this->assertEquals( 4, get_comment_pages_count( $comments, 4, true ) ); + $this->assertSame( 3, get_comment_pages_count( $comments, 10, false ) ); + $this->assertSame( 2, get_comment_pages_count( $comments, 10, true ) ); + $this->assertSame( 4, get_comment_pages_count( $comments, 4, true ) ); } /** @@ -101,17 +101,17 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { update_option( 'thread_comments', false ); - $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) ); - $this->assertEquals( 2, get_comment_pages_count( $comments, 10, true ) ); - $this->assertEquals( 3, get_comment_pages_count( $comments, 10, null ) ); - $this->assertEquals( 3, get_comment_pages_count( $comments, 10 ) ); + $this->assertSame( 3, get_comment_pages_count( $comments, 10, false ) ); + $this->assertSame( 2, get_comment_pages_count( $comments, 10, true ) ); + $this->assertSame( 3, get_comment_pages_count( $comments, 10, null ) ); + $this->assertSame( 3, get_comment_pages_count( $comments, 10 ) ); update_option( 'thread_comments', true ); - $this->assertEquals( 3, get_comment_pages_count( $comments, 10, false ) ); - $this->assertEquals( 2, get_comment_pages_count( $comments, 10, true ) ); - $this->assertEquals( 2, get_comment_pages_count( $comments, 10, null ) ); - $this->assertEquals( 2, get_comment_pages_count( $comments, 10 ) ); + $this->assertSame( 3, get_comment_pages_count( $comments, 10, false ) ); + $this->assertSame( 2, get_comment_pages_count( $comments, 10, true ) ); + $this->assertSame( 2, get_comment_pages_count( $comments, 10, null ) ); + $this->assertSame( 2, get_comment_pages_count( $comments, 10 ) ); } /** @@ -140,8 +140,8 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { update_option( 'comments_per_page', 25 ); - $this->assertEquals( 3, get_comment_pages_count() ); - $this->assertEquals( 2, get_comment_pages_count( null, 20 ) ); + $this->assertSame( 3, get_comment_pages_count() ); + $this->assertSame( 2, get_comment_pages_count( null, 20 ) ); $wp_query = new WP_Query( array( @@ -151,16 +151,16 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase { ) ); - $this->assertEquals( 1, get_comment_pages_count() ); - $this->assertEquals( 5, get_comment_pages_count( null, 5 ) ); + $this->assertSame( 1, get_comment_pages_count() ); + $this->assertSame( 5, get_comment_pages_count( null, 5 ) ); $wp_query->query_vars['comments_per_page'] = null; update_option( 'comments_per_page', 5 ); - $this->assertEquals( 5, get_comment_pages_count() ); - $this->assertEquals( 3, get_comment_pages_count( null, 11 ) ); - $this->assertEquals( 5, get_comment_pages_count( null, 0 ) ); + $this->assertSame( 5, get_comment_pages_count() ); + $this->assertSame( 3, get_comment_pages_count( null, 11 ) ); + $this->assertSame( 5, get_comment_pages_count( null, 0 ) ); } /**