| 258 | * The bulk_edit_posts() function should preserve the post format |
| 259 | * when it's unchanged. |
| 260 | * |
| 261 | * @ticket 44914 |
| 262 | */ |
| 263 | public function test_bulk_edit_posts_should_preserve_post_format_when_unchanged() { |
| 264 | wp_set_current_user( self::$admin_id ); |
| 265 | |
| 266 | $post_ids = self::factory()->post->create_many( 3 ); |
| 267 | |
| 268 | set_post_format( $post_ids[0], 'image' ); |
| 269 | set_post_format( $post_ids[1], 'aside' ); |
| 270 | |
| 271 | $request = array( |
| 272 | 'post_format' => -1, // Don't change the post format. |
| 273 | '_status' => -1, |
| 274 | 'post' => $post_ids, |
| 275 | ); |
| 276 | |
| 277 | bulk_edit_posts( $request ); |
| 278 | |
| 279 | $terms1 = get_the_terms( $post_ids[0], 'post_format' ); |
| 280 | $terms2 = get_the_terms( $post_ids[1], 'post_format' ); |
| 281 | $terms3 = get_the_terms( $post_ids[2], 'post_format' ); |
| 282 | |
| 283 | $this->assertSame( 'post-format-image', $terms1[0]->slug ); |
| 284 | $this->assertSame( 'post-format-aside', $terms2[0]->slug ); |
| 285 | $this->assertFalse( $terms3 ); |
| 286 | |
| 287 | $this->assertSame( 'image', get_post_format( $post_ids[0] ) ); |
| 288 | $this->assertSame( 'aside', get_post_format( $post_ids[1] ) ); |
| 289 | $this->assertFalse( get_post_format( $post_ids[2] ) ); |
| 290 | } |
| 291 | |
| 292 | /** |