Changeset 48937 for trunk/tests/phpunit/tests/customize/nav-menus.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/customize/nav-menus.php
r48858 r48937 47 47 $items[] = array( 48 48 'title' => 'Custom', 49 'type_label' => 'Custom Type', 49 50 'type' => 'custom_type', 50 51 'object' => 'custom_object', 51 'type_label' => 'Custom Type',52 52 ); 53 53 … … 87 87 $this->assertInstanceOf( 'WP_Customize_Manager', $menus->manager ); 88 88 89 $this->assert Equals( 10,add_filter( 'customize_refresh_nonces', array( $menus, 'filter_nonces' ) ) );90 $this->assert Equals( 10,add_action( 'wp_ajax_load-available-menu-items-customizer', array( $menus, 'ajax_load_available_items' ) ) );91 $this->assert Equals( 10,add_action( 'wp_ajax_search-available-menu-items-customizer', array( $menus, 'ajax_search_available_items' ) ) );92 $this->assert Equals( 10,add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $menus, 'ajax_insert_auto_draft_post' ) ) );93 $this->assert Equals( 10,add_action( 'customize_controls_enqueue_scripts', array( $menus, 'enqueue_scripts' ) ) );94 $this->assert Equals( 11,add_action( 'customize_register', array( $menus, 'customize_register' ) ) );95 $this->assert Equals( 10,add_filter( 'customize_dynamic_setting_args', array( $menus, 'filter_dynamic_setting_args' ) ) );96 $this->assert Equals( 10,add_filter( 'customize_dynamic_setting_class', array( $menus, 'filter_dynamic_setting_class' ) ) );97 $this->assert Equals( 10,add_action( 'customize_controls_print_footer_scripts', array( $menus, 'print_templates' ) ) );98 $this->assert Equals( 10,add_action( 'customize_controls_print_footer_scripts', array( $menus, 'available_items_template' ) ) );99 $this->assert Equals( 10,add_action( 'customize_preview_init', array( $menus, 'customize_preview_init' ) ) );100 $this->assert Equals( 10,add_action( 'customize_preview_init', array( $menus, 'make_auto_draft_status_previewable' ) ) );101 $this->assert Equals( 10,add_action( 'customize_save_nav_menus_created_posts', array( $menus, 'save_nav_menus_created_posts' ) ) );102 $this->assert Equals( 10,add_filter( 'customize_dynamic_partial_args', array( $menus, 'customize_dynamic_partial_args' ) ) );89 $this->assertTrue( add_filter( 'customize_refresh_nonces', array( $menus, 'filter_nonces' ) ) ); 90 $this->assertTrue( add_action( 'wp_ajax_load-available-menu-items-customizer', array( $menus, 'ajax_load_available_items' ) ) ); 91 $this->assertTrue( add_action( 'wp_ajax_search-available-menu-items-customizer', array( $menus, 'ajax_search_available_items' ) ) ); 92 $this->assertTrue( add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $menus, 'ajax_insert_auto_draft_post' ) ) ); 93 $this->assertTrue( add_action( 'customize_controls_enqueue_scripts', array( $menus, 'enqueue_scripts' ) ) ); 94 $this->assertTrue( add_action( 'customize_register', array( $menus, 'customize_register' ) ) ); 95 $this->assertTrue( add_filter( 'customize_dynamic_setting_args', array( $menus, 'filter_dynamic_setting_args' ) ) ); 96 $this->assertTrue( add_filter( 'customize_dynamic_setting_class', array( $menus, 'filter_dynamic_setting_class' ) ) ); 97 $this->assertTrue( add_action( 'customize_controls_print_footer_scripts', array( $menus, 'print_templates' ) ) ); 98 $this->assertTrue( add_action( 'customize_controls_print_footer_scripts', array( $menus, 'available_items_template' ) ) ); 99 $this->assertTrue( add_action( 'customize_preview_init', array( $menus, 'customize_preview_init' ) ) ); 100 $this->assertTrue( add_action( 'customize_preview_init', array( $menus, 'make_auto_draft_status_previewable' ) ) ); 101 $this->assertTrue( add_action( 'customize_save_nav_menus_created_posts', array( $menus, 'save_nav_menus_created_posts' ) ) ); 102 $this->assertTrue( add_filter( 'customize_dynamic_partial_args', array( $menus, 'customize_dynamic_partial_args' ) ) ); 103 103 } 104 104 … … 114 114 $items = $menus->load_available_items_query( 'post_type', 'invalid' ); 115 115 $this->assertInstanceOf( 'WP_Error', $items ); 116 $this->assert Equals( 'nav_menus_invalid_post_type', $items->get_error_code() );116 $this->assertSame( 'nav_menus_invalid_post_type', $items->get_error_code() ); 117 117 118 118 // Invalid taxonomy $obj_name. 119 119 $items = $menus->load_available_items_query( 'taxonomy', 'invalid' ); 120 120 $this->assertInstanceOf( 'WP_Error', $items ); 121 $this->assert Equals( 'invalid_taxonomy', $items->get_error_code() );121 $this->assertSame( 'invalid_taxonomy', $items->get_error_code() ); 122 122 } 123 123 … … 318 318 ) 319 319 ); 320 $this->assert Equals( $expected, $results );320 $this->assertSame( $expected, $results ); 321 321 322 322 // Test posts. … … 340 340 ) 341 341 ); 342 $this->assert Equals( $expected, $results[0] );342 $this->assertSame( $expected, $results[0] ); 343 343 } 344 344 … … 362 362 ) 363 363 ); 364 $this->assert Equals( $expected, $results[0] );364 $this->assertSame( $expected, $results[0] ); 365 365 } 366 366 … … 381 381 ) 382 382 ); 383 $this->assert Equals( $count + 1, $this->filter_count_customize_nav_menu_searched_items );383 $this->assertSame( $count + 1, $this->filter_count_customize_nav_menu_searched_items ); 384 384 $this->assertInternalType( 'array', $results ); 385 385 $this->assertCount( 3, $results ); … … 395 395 ); 396 396 $this->assertCount( 1, $results ); 397 $this->assert Equals( 'home', $results[0]['id'] );398 $this->assert Equals( 'custom', $results[0]['type'] );397 $this->assertSame( 'home', $results[0]['id'] ); 398 $this->assertSame( 'custom', $results[0]['type'] ); 399 399 } 400 400 … … 513 513 $expected = array( 'type' => 'nav_menu_item' ); 514 514 $results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu_item[123]' ); 515 $this->assert Equals( $expected['type'], $results['type'] );515 $this->assertSame( $expected['type'], $results['type'] ); 516 516 517 517 $expected = array( 'type' => 'nav_menu' ); 518 518 $results = $menus->filter_dynamic_setting_args( $this->wp_customize, 'nav_menu[123]' ); 519 $this->assert Equals( $expected['type'], $results['type'] );519 $this->assertSame( $expected['type'], $results['type'] ); 520 520 } 521 521 … … 531 531 $expected = 'WP_Customize_Nav_Menu_Item_Setting'; 532 532 $results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu_item[123]', array( 'type' => 'nav_menu_item' ) ); 533 $this->assert Equals( $expected, $results );533 $this->assertSame( $expected, $results ); 534 534 535 535 $expected = 'WP_Customize_Nav_Menu_Setting'; 536 536 $results = $menus->filter_dynamic_setting_class( 'WP_Customize_Setting', 'nav_menu[123]', array( 'type' => 'nav_menu' ) ); 537 $this->assert Equals( $expected, $results );537 $this->assertSame( $expected, $results ); 538 538 } 539 539 … … 560 560 do_action( 'customize_register', $this->wp_customize ); 561 561 $this->assertInstanceOf( 'WP_Customize_Nav_Menu_Item_Setting', $this->wp_customize->get_setting( "nav_menu_item[$item_id]" ) ); 562 $this->assert Equals( 'Primary', $this->wp_customize->get_section( "nav_menu[$menu_id]" )->title );563 $this->assert Equals( 'Hello World', $this->wp_customize->get_control( "nav_menu_item[$item_id]" )->label );562 $this->assertSame( 'Primary', $this->wp_customize->get_section( "nav_menu[$menu_id]" )->title ); 563 $this->assertSame( 'Hello World', $this->wp_customize->get_control( "nav_menu_item[$item_id]" )->label ); 564 564 565 565 $nav_menus_created_posts_setting = $this->wp_customize->get_setting( 'nav_menus_created_posts' ); 566 566 $this->assertInstanceOf( 'WP_Customize_Filter_Setting', $nav_menus_created_posts_setting ); 567 $this->assert Equals( 'postMessage', $nav_menus_created_posts_setting->transport );568 $this->assert Equals( array(), $nav_menus_created_posts_setting->default );569 $this->assert Equals( array( $this->wp_customize->nav_menus, 'sanitize_nav_menus_created_posts' ), $nav_menus_created_posts_setting->sanitize_callback );567 $this->assertSame( 'postMessage', $nav_menus_created_posts_setting->transport ); 568 $this->assertSame( array(), $nav_menus_created_posts_setting->default ); 569 $this->assertSame( array( $this->wp_customize->nav_menus, 'sanitize_nav_menus_created_posts' ), $nav_menus_created_posts_setting->sanitize_callback ); 570 570 } 571 571 … … 579 579 $menus = new WP_Customize_Nav_Menus( $this->wp_customize ); 580 580 581 $this->assert Equals( 2, $menus->intval_base10( 2 ) );582 $this->assert Equals( 4, $menus->intval_base10( 4.1 ) );583 $this->assert Equals( 4, $menus->intval_base10( '4' ) );584 $this->assert Equals( 4, $menus->intval_base10( '04' ) );585 $this->assert Equals( 42, $menus->intval_base10( +42 ) );586 $this->assert Equals( -42, $menus->intval_base10( -42 ) );587 $this->assert Equals( 26, $menus->intval_base10( 0x1A ) );588 $this->assert Equals( 0, $menus->intval_base10( array() ) );581 $this->assertSame( 2, $menus->intval_base10( 2 ) ); 582 $this->assertSame( 4, $menus->intval_base10( 4.1 ) ); 583 $this->assertSame( 4, $menus->intval_base10( '4' ) ); 584 $this->assertSame( 4, $menus->intval_base10( '04' ) ); 585 $this->assertSame( 42, $menus->intval_base10( +42 ) ); 586 $this->assertSame( -42, $menus->intval_base10( -42 ) ); 587 $this->assertSame( 26, $menus->intval_base10( 0x1A ) ); 588 $this->assertSame( 0, $menus->intval_base10( array() ) ); 589 589 } 590 590 … … 601 601 array( 602 602 'title' => 'Posts', 603 'type_label' => __( 'Post' ), 603 604 'type' => 'post_type', 604 605 'object' => 'post', 605 'type_label' => __( 'Post' ),606 606 ), 607 607 array( 608 608 'title' => 'Pages', 609 'type_label' => __( 'Page' ), 609 610 'type' => 'post_type', 610 611 'object' => 'page', 611 'type_label' => __( 'Page' ),612 612 ), 613 613 array( 614 614 'title' => 'Categories', 615 'type_label' => __( 'Category' ), 615 616 'type' => 'taxonomy', 616 617 'object' => 'category', 617 'type_label' => __( 'Category' ),618 618 ), 619 619 array( 620 620 'title' => 'Tags', 621 'type_label' => __( 'Tag' ), 621 622 'type' => 'taxonomy', 622 623 'object' => 'post_tag', 623 'type_label' => __( 'Tag' ),624 624 ), 625 625 ); … … 628 628 $expected[] = array( 629 629 'title' => 'Format', 630 'type_label' => __( 'Format' ), 630 631 'type' => 'taxonomy', 631 632 'object' => 'post_format', 632 'type_label' => __( 'Format' ),633 633 ); 634 634 } 635 635 636 $this->assert Equals( $expected, $menus->available_item_types() );636 $this->assertSame( $expected, $menus->available_item_types() ); 637 637 638 638 register_taxonomy( 'wptests_tax', array( 'post' ), array( 'labels' => array( 'name' => 'Foo' ) ) ); 639 639 $expected[] = array( 640 640 'title' => 'Foo', 641 'type_label' => 'Foo', 641 642 'type' => 'taxonomy', 642 643 'object' => 'wptests_tax', 643 'type_label' => 'Foo', 644 ); 645 646 $this->assertEquals( $expected, $menus->available_item_types() ); 644 ); 645 646 $this->assertSame( $expected, $menus->available_item_types() ); 647 647 648 648 $expected[] = array( 649 649 'title' => 'Custom', 650 'type_label' => 'Custom Type', 650 651 'type' => 'custom_type', 651 652 'object' => 'custom_object', 652 'type_label' => 'Custom Type',653 653 ); 654 654 655 655 add_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); 656 $this->assert Equals( $expected, $menus->available_item_types() );656 $this->assertSame( $expected, $menus->available_item_types() ); 657 657 remove_filter( 'customize_nav_menu_available_item_types', array( $this, 'filter_item_types' ) ); 658 658 … … 669 669 $r = $menus->insert_auto_draft_post( array() ); 670 670 $this->assertInstanceOf( 'WP_Error', $r ); 671 $this->assert Equals( 'unknown_post_type', $r->get_error_code() );671 $this->assertSame( 'unknown_post_type', $r->get_error_code() ); 672 672 673 673 // Non-existent post types allowed as of #39610. … … 679 679 ); 680 680 $this->assertInstanceOf( 'WP_Post', $r ); 681 $this->assert Equals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );681 $this->assertSame( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) ); 682 682 683 683 $r = $menus->insert_auto_draft_post( array( 'post_type' => 'post' ) ); 684 684 $this->assertInstanceOf( 'WP_Error', $r ); 685 $this->assert Equals( 'empty_title', $r->get_error_code() );685 $this->assertSame( 'empty_title', $r->get_error_code() ); 686 686 687 687 $r = $menus->insert_auto_draft_post( … … 693 693 ); 694 694 $this->assertInstanceOf( 'WP_Error', $r ); 695 $this->assert Equals( 'status_forbidden', $r->get_error_code() );695 $this->assertSame( 'status_forbidden', $r->get_error_code() ); 696 696 697 697 $r = $menus->insert_auto_draft_post( … … 702 702 ); 703 703 $this->assertInstanceOf( 'WP_Post', $r ); 704 $this->assert Equals( 'Hello World', $r->post_title );705 $this->assert Equals( '', $r->post_name );706 $this->assert Equals( 'hello-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) );707 $this->assert Equals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );708 $this->assert Equals( 'post', $r->post_type );704 $this->assertSame( 'Hello World', $r->post_title ); 705 $this->assertSame( '', $r->post_name ); 706 $this->assertSame( 'hello-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) ); 707 $this->assertSame( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) ); 708 $this->assertSame( 'post', $r->post_type ); 709 709 710 710 $r = $menus->insert_auto_draft_post( … … 717 717 ); 718 718 $this->assertInstanceOf( 'WP_Post', $r ); 719 $this->assert Equals( 'Hello World', $r->post_title );720 $this->assert Equals( 'post', $r->post_type );721 $this->assert Equals( '', $r->post_name );722 $this->assert Equals( 'greetings-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) );723 $this->assert Equals( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) );724 $this->assert Equals( 'Hi World', $r->post_content );719 $this->assertSame( 'Hello World', $r->post_title ); 720 $this->assertSame( 'post', $r->post_type ); 721 $this->assertSame( '', $r->post_name ); 722 $this->assertSame( 'greetings-world', get_post_meta( $r->ID, '_customize_draft_post_name', true ) ); 723 $this->assertSame( $this->wp_customize->changeset_uuid(), get_post_meta( $r->ID, '_customize_changeset_uuid', true ) ); 724 $this->assertSame( 'Hi World', $r->post_content ); 725 725 } 726 726 … … 806 806 $args = apply_filters( 'customize_dynamic_partial_args', false, 'nav_menu_instance[68b329da9893e34099c7d8ad5cb9c940]' ); 807 807 $this->assertInternalType( 'array', $args ); 808 $this->assert Equals( 'nav_menu_instance', $args['type'] );809 $this->assert Equals( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );808 $this->assertSame( 'nav_menu_instance', $args['type'] ); 809 $this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] ); 810 810 $this->assertTrue( $args['container_inclusive'] ); 811 811 812 812 $args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'nav_menu_instance[4099c7d8ad5cb9c94068b329da9893e3]' ); 813 813 $this->assertInternalType( 'array', $args ); 814 $this->assert Equals( 'nav_menu_instance', $args['type'] );815 $this->assert Equals( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] );814 $this->assertSame( 'nav_menu_instance', $args['type'] ); 815 $this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] ); 816 816 $this->assertTrue( $args['container_inclusive'] ); 817 817 $this->assertFalse( $args['fallback_refresh'] ); … … 828 828 829 829 $menus->customize_preview_init(); 830 $this->assert Equals( 10, has_action( 'wp_enqueue_scripts', array( $menus, 'customize_preview_enqueue_deps' ) ) );831 $this->assert Equals( 1000, has_filter( 'wp_nav_menu_args', array( $menus, 'filter_wp_nav_menu_args' ) ) );832 $this->assert Equals( 10, has_filter( 'wp_nav_menu', array( $menus, 'filter_wp_nav_menu' ) ) );830 $this->assertSame( 10, has_action( 'wp_enqueue_scripts', array( $menus, 'customize_preview_enqueue_deps' ) ) ); 831 $this->assertSame( 1000, has_filter( 'wp_nav_menu_args', array( $menus, 'filter_wp_nav_menu_args' ) ) ); 832 $this->assertSame( 10, has_filter( 'wp_nav_menu', array( $menus, 'filter_wp_nav_menu' ) ) ); 833 833 } 834 834 … … 908 908 wp_set_current_user( $contributor_user_id ); 909 909 $sanitized = $menus->sanitize_nav_menus_created_posts( $value ); 910 $this->assert Equals( array(), $sanitized );910 $this->assertSame( array(), $sanitized ); 911 911 912 912 wp_set_current_user( $author_user_id ); 913 913 $sanitized = $menus->sanitize_nav_menus_created_posts( $value ); 914 $this->assert Equals( array( $author_post_id ), $sanitized );914 $this->assertSame( array( $author_post_id ), $sanitized ); 915 915 916 916 wp_set_current_user( $administrator_user_id ); 917 917 $sanitized = $menus->sanitize_nav_menus_created_posts( $value ); 918 $this->assert Equals( array( $contributor_post_id, $author_post_id, $administrator_post_id, $draft_post_id ), $sanitized );918 $this->assertSame( array( $contributor_post_id, $author_post_id, $administrator_post_id, $draft_post_id ), $sanitized ); 919 919 } 920 920 … … 997 997 $setting = $this->wp_customize->get_setting( $setting_id ); 998 998 $this->assertInstanceOf( 'WP_Customize_Filter_Setting', $setting ); 999 $this->assert Equals( array( $menus, 'sanitize_nav_menus_created_posts' ), $setting->sanitize_callback );1000 $this->assert Equals( $drafted_post_ids, $setting->post_value() );999 $this->assertSame( array( $menus, 'sanitize_nav_menus_created_posts' ), $setting->sanitize_callback ); 1000 $this->assertSame( $drafted_post_ids, $setting->post_value() ); 1001 1001 $this->assertArrayNotHasKey( $private_post_id, $post_ids ); 1002 1002 $this->assertArrayNotHasKey( $trashed_post_id, $post_ids ); 1003 1003 1004 $this->assert Equals( 'auto-draft', get_post_status( $drafted_post_ids[0] ) );1005 $this->assert Equals( 'draft', get_post_status( $drafted_post_ids[1] ) );1004 $this->assertSame( 'auto-draft', get_post_status( $drafted_post_ids[0] ) ); 1005 $this->assertSame( 'draft', get_post_status( $drafted_post_ids[1] ) ); 1006 1006 foreach ( $drafted_post_ids as $post_id ) { 1007 1007 $this->assertEmpty( get_post( $post_id )->post_name ); … … 1011 1011 $save_action_count = did_action( 'customize_save_nav_menus_created_posts' ); 1012 1012 $setting->save(); 1013 $this->assert Equals( $save_action_count + 1, did_action( 'customize_save_nav_menus_created_posts' ) );1013 $this->assertSame( $save_action_count + 1, did_action( 'customize_save_nav_menus_created_posts' ) ); 1014 1014 foreach ( $drafted_post_ids as $post_id ) { 1015 $this->assert Equals( 'publish', get_post_status( $post_id ) );1015 $this->assertSame( 'publish', get_post_status( $post_id ) ); 1016 1016 $this->assertRegExp( '/^auto-draft-\d+$/', get_post( $post_id )->post_name ); 1017 1017 $this->assertEmpty( get_post_meta( $post_id, '_customize_draft_post_name', true ) ); 1018 1018 } 1019 1019 1020 $this->assert Equals( 'private', get_post_status( $private_post_id ) );1021 $this->assert Equals( 'trash', get_post_status( $trashed_post_id ) );1020 $this->assertSame( 'private', get_post_status( $private_post_id ) ); 1021 $this->assertSame( 'trash', get_post_status( $trashed_post_id ) ); 1022 1022 1023 1023 // Ensure that unique slugs were assigned. … … 1059 1059 $this->assertFalse( $results['can_partial_refresh'] ); 1060 1060 $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results ); 1061 $this->assert Equals( 'wp_page_menu', $results['fallback_cb'] );1061 $this->assertSame( 'wp_page_menu', $results['fallback_cb'] ); 1062 1062 1063 1063 $nav_menu_term = get_term( wp_create_nav_menu( 'Bar' ) ); … … 1073 1073 $this->assertTrue( $results['can_partial_refresh'] ); 1074 1074 $this->assertArrayHasKey( 'customize_preview_nav_menus_args', $results ); 1075 $this->assert Equals( $nav_menu_term->term_id, $results['customize_preview_nav_menus_args']['menu'] );1075 $this->assertSame( $nav_menu_term->term_id, $results['customize_preview_nav_menus_args']['menu'] ); 1076 1076 1077 1077 $results = $menus->filter_wp_nav_menu_args( … … 1145 1145 $this->assertTrue( (bool) preg_match( '/data-customize-partial-placement-context="(.+?)"/', $result, $matches ) ); 1146 1146 $context = json_decode( html_entity_decode( $matches[1] ), true ); 1147 $this->assert Equals( $original_args, wp_array_slice_assoc( $context, array_keys( $original_args ) ) ); // Because assertArraySubset is not available in PHP 5.2.1147 $this->assertSame( $original_args, wp_array_slice_assoc( $context, array_keys( $original_args ) ) ); // Because assertArraySubset is not available in PHP 5.2. 1148 1148 $this->assertTrue( $context['can_partial_refresh'] ); 1149 1149 } … … 1211 1211 $this->assertNotEmpty( $partials ); 1212 1212 $partial = array_shift( $partials ); 1213 $this->assert Equals( $partial_id, $partial->id );1213 $this->assertSame( $partial_id, $partial->id ); 1214 1214 1215 1215 $missing_args_hmac_args = array_merge(
Note: See TracChangeset
for help on using the changeset viewer.