| 348 | |
| 349 | /** |
| 350 | * @ticket 22247 |
| 351 | */ |
| 352 | public function test_admin_bar_has_edit_link_for_existing_posts() { |
| 353 | wp_set_current_user( self::$editor_id ); |
| 354 | |
| 355 | $post = array( |
| 356 | 'post_author' => self::$editor_id, |
| 357 | 'post_status' => 'publish', |
| 358 | 'post_content' => rand_str(), |
| 359 | 'post_title' => rand_str(), |
| 360 | ); |
| 361 | $id = wp_insert_post( $post ); |
| 362 | |
| 363 | // Set queried object to the newly created post. |
| 364 | global $wp_the_query; |
| 365 | $wp_the_query->queried_object = (object) array( 'ID' => $id, 'post_type' => 'post' ); |
| 366 | |
| 367 | $wp_admin_bar = $this->get_standard_admin_bar(); |
| 368 | |
| 369 | $node_edit = $wp_admin_bar->get_node( 'edit' ); |
| 370 | $this->assertNotNull( $node_edit ); |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * @ticket 22247 |
| 375 | */ |
| 376 | public function test_admin_bar_has_no_edit_link_for_non_existing_posts() { |
| 377 | wp_set_current_user( self::$editor_id ); |
| 378 | |
| 379 | // Set queried object to a non-existing post. |
| 380 | global $wp_the_query; |
| 381 | $wp_the_query->queried_object = (object) array( 'ID' => 0, 'post_type' => 'post' ); |
| 382 | |
| 383 | $wp_admin_bar = $this->get_standard_admin_bar(); |
| 384 | |
| 385 | $node_edit = $wp_admin_bar->get_node( 'edit' ); |
| 386 | $this->assertNull( $node_edit ); |
| 387 | } |
| 388 | |