You appear to be a bot. Output may be restricted
Description
Test the available_items_template method.
Usage
Test_WP_Customize_Nav_Menus::test_available_items_template();
Parameters
Returns
void
Source
File name: wordpress-develop-tests/phpunit/tests/customize/nav-menus.php
Lines:
1 to 42 of 42
public function test_available_items_template() { add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); do_action( 'customize_register', $this->wp_customize ); $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); ob_start(); $menus->available_items_template(); $template = ob_get_clean(); $expected = sprintf( 'Customizing ▸ %s', esc_html( $this->wp_customize->get_panel( 'nav_menus' )->title ) ); $this->assertStringContainsString( $expected, $template ); $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); if ( $post_types ) { foreach ( $post_types as $type ) { $this->assertStringContainsString( 'available-menu-items-post_type-' . esc_attr( $type->name ), $template ); $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $type->labels->name ) . '#', $template ); $this->assertStringContainsString( 'data-type="post_type"', $template ); $this->assertStringContainsString( 'data-object="' . esc_attr( $type->name ) . '"', $template ); $this->assertStringContainsString( 'data-type_label="' . esc_attr( $type->labels->singular_name ) . '"', $template ); } } $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); if ( $taxonomies ) { foreach ( $taxonomies as $tax ) { $this->assertStringContainsString( 'available-menu-items-taxonomy-' . esc_attr( $tax->name ), $template ); $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*' . esc_html( $tax->labels->name ) . '#', $template ); $this->assertStringContainsString( 'data-type="taxonomy"', $template ); $this->assertStringContainsString( 'data-object="' . esc_attr( $tax->name ) . '"', $template ); $this->assertStringContainsString( 'data-type_label="' . esc_attr( $tax->labels->singular_name ) . '"', $template ); } } $this->assertStringContainsString( 'available-menu-items-custom_type', $template ); $this->assertMatchesRegularExpression( '#<h4 class="accordion-section-title".*>\s*Custom#', $template ); $this->assertStringContainsString( 'data-type="custom_type"', $template ); $this->assertStringContainsString( 'data-object="custom_object"', $template ); $this->assertStringContainsString( 'data-type_label="Custom Type"', $template ); }