Changeset 58762 for branches/6.6
- Timestamp:
- 07/18/2024 05:56:35 PM (3 months ago)
- Location:
- branches/6.6
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.6
- Property svn:mergeinfo changed
/trunk merged: 58755-58756
- Property svn:mergeinfo changed
-
branches/6.6/src/wp-includes/comment-template.php
r58335 r58762 25 25 $comment = get_comment( $comment_id ); 26 26 27 $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id; 27 if ( ! empty( $comment->comment_ID ) ) { 28 $comment_id = $comment->comment_ID; 29 } elseif ( is_scalar( $comment_id ) ) { 30 $comment_id = (string) $comment_id; 31 } else { 32 $comment_id = ''; 33 } 28 34 29 35 if ( empty( $comment->comment_author ) ) { -
branches/6.6/tests/phpunit/tests/comment/getCommentAuthor.php
r58335 r58762 57 57 get_comment_author( self::$non_existent_comment_id ); // Non-existent comment ID. 58 58 } 59 60 /** 61 * @ticket 61681 62 * 63 * @dataProvider data_should_return_author_when_given_object_without_comment_id 64 * 65 * @param stdClass $comment_props Comment properties test data. 66 * @param string $expected The expected result. 67 * @param array $user_data Optional. User data for creating an author. Default empty array. 68 */ 69 public function test_should_return_author_when_given_object_without_comment_id( $comment_props, $expected, $user_data = array() ) { 70 if ( ! empty( $comment_props->user_id ) ) { 71 $user = self::factory()->user->create_and_get( $user_data ); 72 $comment_props->user_id = $user->ID; 73 } 74 $comment = new WP_Comment( $comment_props ); 75 $this->assertSame( $expected, get_comment_author( $comment ) ); 76 } 77 78 /** 79 * Data provider. 80 * 81 * @return array 82 */ 83 public function data_should_return_author_when_given_object_without_comment_id() { 84 return array( 85 'with no author' => array( 86 'comment_props' => new stdClass(), 87 'expected' => 'Anonymous', 88 ), 89 'with author name' => array( 90 'comment_props' => (object) array( 91 'comment_author' => 'tester1', 92 ), 93 'expected' => 'tester1', 94 ), 95 'with author name, empty ID' => array( 96 'comment_props' => (object) array( 97 'comment_author' => 'tester2', 98 'comment_ID' => '', 99 ), 100 'expected' => 'tester2', 101 ), 102 'with author ID' => array( 103 'comment_props' => (object) array( 104 'user_id' => 1, // Populates in the test with an actual user ID. 105 ), 106 'expected' => 'Tester3', 107 'user_data' => array( 108 'display_name' => 'Tester3', 109 ), 110 ), 111 ); 112 } 59 113 }
Note: See TracChangeset
for help on using the changeset viewer.