Changeset 45013 for branches/4.0/tests/phpunit/tests/taxonomy.php
- Timestamp:
- 03/26/2019 12:45:57 AM (5 years ago)
- Location:
- branches/4.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0
- Property svn:mergeinfo changed
/trunk merged: 29860,29869,29954,30160,30530
- Property svn:mergeinfo changed
-
branches/4.0/tests/phpunit/tests/taxonomy.php
r28926 r45013 34 34 } 35 35 36 function test_get_the_taxonomies() {37 $post_id = $this->factory->post->create();38 39 $taxes = get_the_taxonomies( $post_id );40 $this->assertNotEmpty( $taxes );41 $this->assertEquals( array( 'category' ), array_keys( $taxes ) );42 43 $id = $this->factory->tag->create();44 wp_set_post_tags( $post_id, array( $id ) );45 46 $taxes = get_the_taxonomies( $post_id );47 $this->assertNotEmpty( $taxes );48 $this->assertCount( 2, $taxes );49 $this->assertEquals( array( 'category', 'post_tag' ), array_keys( $taxes ) );50 }51 52 36 function test_the_taxonomies() { 53 37 $post_id = $this->factory->post->create(); … … 135 119 } 136 120 137 /**138 * @ticket 11058139 */140 function test_registering_taxonomies_to_object_types() {141 // Create a taxonomy to test with142 $tax = 'test_tax';143 $this->assertFalse( taxonomy_exists($tax) );144 register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) );145 146 // Create a post type to test with147 $post_type = 'test_cpt';148 $this->assertFalse( get_post_type( $post_type ) );149 $this->assertObjectHasAttribute( 'name', register_post_type( $post_type ) );150 151 // Core taxonomy, core post type152 $this->assertTrue( unregister_taxonomy_for_object_type( 'category', 'post' ) );153 $this->assertFalse( unregister_taxonomy_for_object_type( 'category', 'post' ) );154 $this->assertTrue( register_taxonomy_for_object_type( 'category', 'post' ) );155 156 // Core taxonomy, non-core post type157 $this->assertTrue( register_taxonomy_for_object_type( 'category', $post_type ) );158 $this->assertTrue( unregister_taxonomy_for_object_type( 'category', $post_type ) );159 $this->assertFalse( unregister_taxonomy_for_object_type( 'category', $post_type ) );160 $this->assertTrue( register_taxonomy_for_object_type( 'category', $post_type ) );161 162 // Core taxonomies, non-post object types163 $this->assertFalse( register_taxonomy_for_object_type( 'category', 'user' ) );164 $this->assertFalse( unregister_taxonomy_for_object_type( 'category', 'user' ) );165 166 // Non-core taxonomy, core post type167 $this->assertTrue( unregister_taxonomy_for_object_type( $tax, 'post' ) );168 $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'post' ) );169 $this->assertTrue( register_taxonomy_for_object_type( $tax, 'post' ) );170 171 // Non-core taxonomy, non-core post type172 $this->assertTrue( register_taxonomy_for_object_type( $tax, $post_type ) );173 $this->assertTrue( unregister_taxonomy_for_object_type( $tax, $post_type ) );174 $this->assertFalse( unregister_taxonomy_for_object_type( $tax, $post_type ) );175 $this->assertTrue( register_taxonomy_for_object_type( $tax, $post_type ) );176 177 // Non-core taxonomies, non-post object types178 $this->assertFalse( register_taxonomy_for_object_type( $tax, 'user' ) );179 $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'user' ) );180 181 unset($GLOBALS['wp_taxonomies'][$tax]);182 _unregister_post_type( $post_type );183 184 }185 121 /** 186 122 * @ticket 25706
Note: See TracChangeset
for help on using the changeset viewer.