/** * Test misc admin bar extensions. * * @covers CustomizeSnapshots\Customize_Snapshot_Manager::add_post_edit_screen_link() * @covers CustomizeSnapshots\Customize_Snapshot_Manager::add_snapshot_exit_link() * @covers CustomizeSnapshots\Customize_Snapshot_Manager::add_resume_snapshot_link() * @covers CustomizeSnapshots\Customize_Snapshot_Manager::remove_all_non_snapshot_admin_bar_links() */ public function test_add_post_edit_and_exit_links() { global $wp_admin_bar; set_current_screen('front'); require_once ABSPATH . WPINC . '/class-wp-admin-bar.php'; $this->manager->post_type->save(array('uuid' => self::UUID, 'data' => array('blogname' => array('value' => 'Hello')), 'status' => 'draft')); remove_all_actions('admin_bar_menu'); $manager = new Customize_Snapshot_Manager($this->plugin); $manager->init(); $wp_admin_bar = new \WP_Admin_Bar(); // WPCS: Override OK. $wp_admin_bar->initialize(); $wp_admin_bar->add_menus(); do_action_ref_array('admin_bar_menu', array(&$wp_admin_bar)); $this->assertEmpty($wp_admin_bar->get_node('inspect-customize-snapshot')); $this->assertEmpty($wp_admin_bar->get_node('exit-customize-snapshot')); $this->assertNotEmpty($wp_admin_bar->get_node('wporg')); $this->assertNotEmpty($wp_admin_bar->get_node('resume-customize-snapshot')); $this->go_to(home_url('?customize_snapshot_uuid=' . self::UUID)); $_REQUEST['customize_snapshot_uuid'] = self::UUID; remove_all_actions('admin_bar_menu'); $manager = new Customize_Snapshot_Manager($this->plugin); $manager->init(); $wp_admin_bar = new \WP_Admin_Bar(); // WPCS: Override OK. $wp_admin_bar->initialize(); $wp_admin_bar->add_menus(); do_action_ref_array('admin_bar_menu', array(&$wp_admin_bar)); $this->assertNotEmpty($wp_admin_bar->get_node('inspect-customize-snapshot')); $this->assertNotEmpty($wp_admin_bar->get_node('exit-customize-snapshot')); $this->assertEmpty($wp_admin_bar->get_node('wporg')); $this->assertNotEmpty($wp_admin_bar->get_node('resume-customize-snapshot')); }