- Timestamp:
- 10/08/2019 04:00:25 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r43571 r46433 14 14 protected static $admin_id; 15 15 protected static $editor_id; 16 protected static $moderator_id; 16 17 protected static $subscriber_id; 17 18 protected static $author_id; … … 28 29 29 30 public static function wpSetUpBeforeClass( $factory ) { 31 add_role( 32 'comment_moderator', 33 'Comment Moderator', 34 array( 35 'read' => true, 36 'moderate_comments' => true, 37 ) 38 ); 39 30 40 self::$superadmin_id = $factory->user->create( 31 41 array( … … 42 52 array( 43 53 'role' => 'editor', 54 ) 55 ); 56 self::$moderator_id = $factory->user->create( 57 array( 58 'role' => 'comment_moderator', 44 59 ) 45 60 ); … … 99 114 100 115 public static function wpTearDownAfterClass() { 116 remove_role( 'comment_moderator' ); 117 101 118 self::delete_user( self::$superadmin_id ); 102 119 self::delete_user( self::$admin_id ); 103 120 self::delete_user( self::$editor_id ); 121 self::delete_user( self::$moderator_id ); 104 122 self::delete_user( self::$subscriber_id ); 105 123 self::delete_user( self::$author_id ); … … 2481 2499 } 2482 2500 2501 /** 2502 * @ticket 47024 2503 */ 2504 public function test_update_comment_when_can_moderate_comments() { 2505 wp_set_current_user( self::$moderator_id ); 2506 2507 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/comments/%d', self::$approved_id ) ); 2508 $params = array( 2509 'content' => 'Updated comment.', 2510 'date' => '2019-10-07T23:14:25', 2511 ); 2512 $request->add_header( 'content-type', 'application/json' ); 2513 $request->set_body( wp_json_encode( $params ) ); 2514 2515 $response = rest_get_server()->dispatch( $request ); 2516 $this->assertEquals( 200, $response->get_status() ); 2517 2518 $comment = $response->get_data(); 2519 $updated = get_comment( self::$approved_id ); 2520 2521 $this->assertEquals( $params['content'], $updated->comment_content ); 2522 $this->assertEquals( self::$post_id, $comment['post'] ); 2523 $this->assertEquals( '2019-10-07T23:14:25', $comment['date'] ); 2524 } 2525 2483 2526 public function test_update_comment_private_post_invalid_permission() { 2484 2527 $private_comment_id = $this->factory->comment->create(
Note: See TracChangeset
for help on using the changeset viewer.