- Timestamp:
- 05/26/2025 02:34:12 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/wpHandleCommentSubmission.php
r59319 r60253 10 10 protected static $post; 11 11 protected static $author_id; 12 protected static $author_id2; 12 13 protected static $editor_id; 13 14 … … 20 21 array( 21 22 'role' => 'author', 23 ) 24 ); 25 26 self::$author_id2 = $factory->user->create( 27 array( 28 'role' => 'author', 29 'user_url' => 'http://user.example.org', 22 30 ) 23 31 ); … … 224 232 public function test_submitting_valid_comment_as_logged_in_user_succeeds() { 225 233 226 $user = self::factory()->user->create_and_get( 227 array( 228 'user_url' => 'http://user.example.org', 229 ) 230 ); 234 $user = get_user_by( 'id', self::$author_id2 ); 231 235 232 236 wp_set_current_user( $user->ID ); … … 315 319 $error = 'comment_id_not_found'; 316 320 317 $user = self::factory()->user->create_and_get( 318 array( 319 'role' => 'author', 320 ) 321 ); 321 $user = get_user_by( 'id', self::$author_id2 ); 322 322 323 323 wp_set_current_user( $user->ID ); … … 344 344 $error = 'comment_id_not_found'; 345 345 346 $user = self::factory()->user->create_and_get( 347 array( 348 'role' => 'author', 349 ) 350 ); 346 $user = get_user_by( 'id', self::$author_id2 ); 351 347 352 348 wp_set_current_user( $user->ID ); … … 835 831 * @ticket 36901 836 832 */ 837 public function test_comments_flood_user_is_admin() { 838 $user = self::factory()->user->create_and_get( 839 array( 840 'role' => 'administrator', 841 ) 842 ); 833 public function test_comments_flood_user_can_moderate_comments() { 834 $user = get_user_by( 'id', self::$editor_id ); 843 835 wp_set_current_user( $user->ID ); 844 836 … … 854 846 $second_comment = wp_handle_comment_submission( $data ); 855 847 856 $this->assertNotWPError( $second_comment ); 857 $this->assertSame( (string) self::$post->ID, $second_comment->comment_post_ID ); 848 $this->assertTrue( current_user_can( 'moderate_comments' ), 'Test user should have the moderate_comments capability' ); 849 $this->assertNotWPError( $second_comment, 'Second comment should not trigger comment flooding error.' ); 850 $this->assertSame( (string) self::$post->ID, $second_comment->comment_post_ID, 'Second comment should be made against initial post.' ); 858 851 } 859 852
Note: See TracChangeset
for help on using the changeset viewer.