Changeset 49332 for branches/5.5/tests/phpunit/tests/taxonomy.php
- Timestamp:
- 10/27/2020 05:54:43 PM (4 years ago)
- Location:
- branches/5.5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.5
-
branches/5.5/tests/phpunit/tests/taxonomy.php
r48665 r49332 993 993 994 994 // Add post. 995 $post_id = wp_insert_post(995 $post_id = self::factory()->post->create( 996 996 array( 997 997 'post_title' => 'Foo', … … 1000 1000 ); 1001 1001 1002 // Test default category.1002 // Test default term. 1003 1003 $term = wp_get_post_terms( $post_id, $tax ); 1004 1004 $this->assertSame( get_option( 'default_term_' . $tax ), $term[0]->term_id ); … … 1014 1014 ) 1015 1015 ); 1016 $post_id = wp_insert_post(1016 $post_id = self::factory()->post->create( 1017 1017 array( 1018 1018 'post_title' => 'Foo', … … 1020 1020 ) 1021 1021 ); 1022 $term = wp_get_post_terms( $post_id, $tax ); 1022 1023 // Test default term. 1024 $term = wp_get_post_terms( $post_id, $tax ); 1023 1025 $this->assertSame( get_option( 'default_term_' . $tax ), $term[0]->term_id ); 1024 1026 1025 // wp_set_object_terms shouldn't assign default category.1027 // wp_set_object_terms() should not assign default term. 1026 1028 wp_set_object_terms( $post_id, array(), $tax ); 1027 1029 $term = wp_get_post_terms( $post_id, $tax ); … … 1031 1033 $this->assertSame( get_option( 'default_term_' . $tax ), false ); 1032 1034 } 1035 1036 /** 1037 * @ticket 51320 1038 */ 1039 function test_default_term_for_post_in_multiple_taxonomies() { 1040 $post_type = 'test_post_type'; 1041 $tax1 = 'test_tax1'; 1042 $tax2 = 'test_tax2'; 1043 1044 register_post_type( $post_type, array( 'taxonomies' => array( $tax1, $tax2 ) ) ); 1045 register_taxonomy( $tax1, $post_type, array( 'default_term' => 'term_1' ) ); 1046 register_taxonomy( $tax2, $post_type, array( 'default_term' => 'term_2' ) ); 1047 1048 $post_id = self::factory()->post->create( array( 'post_type' => $post_type ) ); 1049 1050 $taxonomies = get_post_taxonomies( $post_id ); 1051 1052 $this->assertContains( $tax1, $taxonomies ); 1053 $this->assertContains( $tax2, $taxonomies ); 1054 } 1033 1055 }
Note: See TracChangeset
for help on using the changeset viewer.