| 78 | * @ticket 33154 |
| 79 | */ |
| 80 | function test_editor_can_edit_orphan_comments() { |
| 81 | global $wpdb; |
| 82 | |
| 83 | // Become an editor |
| 84 | $this->_setRole( 'editor' ); |
| 85 | |
| 86 | // Get a comment |
| 87 | $comments = get_comments( array( |
| 88 | 'post_id' => $this->_comment_post->ID |
| 89 | ) ); |
| 90 | $comment = array_pop( $comments ); |
| 91 | |
| 92 | // Manually update the comment_post_ID, because wp_update_comment() will prevent it. |
| 93 | $wpdb->query( "UPDATE {$wpdb->comments} SET comment_post_ID=0 WHERE comment_ID={$comment->comment_ID}" ); |
| 94 | clean_comment_cache( $comment->comment_ID ); |
| 95 | |
| 96 | // Set up a default request |
| 97 | $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' ); |
| 98 | $_POST['comment_ID'] = $comment->comment_ID; |
| 99 | $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; |
| 100 | |
| 101 | // Make the request |
| 102 | try { |
| 103 | $this->_handleAjax( 'edit-comment' ); |
| 104 | } catch ( WPAjaxDieContinueException $e ) { |
| 105 | unset( $e ); |
| 106 | } |
| 107 | |
| 108 | // Get the response |
| 109 | $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA ); |
| 110 | |
| 111 | // Check the meta data |
| 112 | $this->assertEquals( -1, (string) $xml->response[0]->edit_comment['position'] ); |
| 113 | $this->assertEquals( $comment->comment_ID, (string) $xml->response[0]->edit_comment['id'] ); |
| 114 | $this->assertEquals( 'edit-comment_' . $comment->comment_ID, (string) $xml->response['action'] ); |
| 115 | |
| 116 | // Check the payload |
| 117 | $this->assertNotEmpty( (string) $xml->response[0]->edit_comment[0]->response_data ); |
| 118 | |
| 119 | // And supplemental is empty |
| 120 | $this->assertEmpty( (string) $xml->response[0]->edit_comment[0]->supplemental ); |
| 121 | } |
| 122 | |
| 123 | /** |