| 139 | /** |
| 140 | * @ticket 27792 |
| 141 | */ |
| 142 | function test_bulk_edit_posts() { |
| 143 | $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); |
| 144 | $users = $this->factory->user->create_many( 2, array( 'role' => 'author' ) ); |
| 145 | wp_set_current_user( $user_id ); |
| 146 | |
| 147 | $post1 = $this->factory->post->create( array( |
| 148 | 'post_author' => $users[0], |
| 149 | 'comment_status' => 'open', |
| 150 | 'ping_status' => 'open', |
| 151 | ) ); |
| 152 | |
| 153 | $post2 = $this->factory->post->create( array( |
| 154 | 'post_author' => $users[1], |
| 155 | 'comment_status' => 'closed', |
| 156 | 'ping_status' => 'closed', |
| 157 | ) ); |
| 158 | |
| 159 | $post2_clone = $post2; |
| 160 | |
| 161 | $request = array( |
| 162 | 's' => null, |
| 163 | 'post_status' => 'all', |
| 164 | 'post_type' => 'post', |
| 165 | '_wpnonce' => rand_str( 10 ), |
| 166 | '_wp_http_referer' => '/wp-admin/edit.php', |
| 167 | 'action' => 'edit', |
| 168 | 'm' => 0, |
| 169 | 'cat' => 0, |
| 170 | 'paged' => 1, |
| 171 | 'model' => 'list', |
| 172 | 'post_author' => -1, |
| 173 | 'ping_status' => null, |
| 174 | '_status' => -1, |
| 175 | 'sticky' => -1, |
| 176 | 'post_format' => 'image', |
| 177 | 'post' => array( $post1, $post2_clone ), |
| 178 | 'action2' => -1, |
| 179 | ); |
| 180 | |
| 181 | $done = bulk_edit_posts( $request ); |
| 182 | |
| 183 | $post2 = get_post( $post2 ); |
| 184 | $post2_clone = get_post( $post2_clone ); |
| 185 | |
| 186 | $this->assertEquals( $post2->post_author, $post2_clone->post_author ); |
| 187 | $this->assertEquals( 'closed', $post2_clone->comment_status ); |
| 188 | $this->assertEquals( 'closed', $post2_clone->ping_status ); |
| 189 | |
| 190 | wp_set_current_user( 0 ); |
| 191 | } |
| 192 | |