Changeset 47122 for trunk/tests/phpunit/tests/taxonomy.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/taxonomy.php
r46586 r47122 17 17 */ 18 18 function test_get_unknown_taxonomies() { 19 // taxonomies for an unknown object type19 // Taxonomies for an unknown object type. 20 20 $this->assertEquals( array(), get_object_taxonomies( rand_str() ) ); 21 21 $this->assertEquals( array(), get_object_taxonomies( '' ) ); … … 27 27 foreach ( get_object_taxonomies( 'post' ) as $taxonomy ) { 28 28 $tax = get_taxonomy( $taxonomy ); 29 // should return an object with the correct taxonomy object type29 // Should return an object with the correct taxonomy object type. 30 30 $this->assertTrue( is_object( $tax ) ); 31 31 $this->assertTrue( is_array( $tax->object_type ) ); … … 109 109 foreach ( get_object_taxonomies( 'link' ) as $taxonomy ) { 110 110 $tax = get_taxonomy( $taxonomy ); 111 // should return an object with the correct taxonomy object type111 // Should return an object with the correct taxonomy object type. 112 112 $this->assertTrue( is_object( $tax ) ); 113 113 $this->assertTrue( is_array( $tax->object_type ) ); … … 144 144 function test_register_taxonomy() { 145 145 146 // make up a new taxonomy name, and ensure it's unused146 // Make up a new taxonomy name, and ensure it's unused. 147 147 $tax = rand_str(); 148 148 $this->assertFalse( taxonomy_exists( $tax ) ); … … 152 152 $this->assertFalse( is_taxonomy_hierarchical( $tax ) ); 153 153 154 // clean up154 // Clean up. 155 155 unset( $GLOBALS['wp_taxonomies'][ $tax ] ); 156 156 } … … 158 158 function test_register_hierarchical_taxonomy() { 159 159 160 // make up a new taxonomy name, and ensure it's unused160 // Make up a new taxonomy name, and ensure it's unused. 161 161 $tax = rand_str(); 162 162 $this->assertFalse( taxonomy_exists( $tax ) ); … … 166 166 $this->assertTrue( is_taxonomy_hierarchical( $tax ) ); 167 167 168 // clean up168 // Clean up. 169 169 unset( $GLOBALS['wp_taxonomies'][ $tax ] ); 170 170 } … … 219 219 */ 220 220 function test_registering_taxonomies_to_object_types() { 221 // Create a taxonomy to test with 221 // Create a taxonomy to test with. 222 222 $tax = 'test_tax'; 223 223 $this->assertFalse( taxonomy_exists( $tax ) ); 224 224 register_taxonomy( $tax, 'post', array( 'hierarchical' => true ) ); 225 225 226 // Create a post type to test with 226 // Create a post type to test with. 227 227 $post_type = 'test_cpt'; 228 228 $this->assertFalse( get_post_type( $post_type ) ); 229 229 $this->assertObjectHasAttribute( 'name', register_post_type( $post_type ) ); 230 230 231 // Core taxonomy, core post type 231 // Core taxonomy, core post type. 232 232 $this->assertTrue( unregister_taxonomy_for_object_type( 'category', 'post' ) ); 233 233 $this->assertFalse( unregister_taxonomy_for_object_type( 'category', 'post' ) ); 234 234 $this->assertTrue( register_taxonomy_for_object_type( 'category', 'post' ) ); 235 235 236 // Core taxonomy, non-core post type 236 // Core taxonomy, non-core post type. 237 237 $this->assertTrue( register_taxonomy_for_object_type( 'category', $post_type ) ); 238 238 $this->assertTrue( unregister_taxonomy_for_object_type( 'category', $post_type ) ); … … 240 240 $this->assertTrue( register_taxonomy_for_object_type( 'category', $post_type ) ); 241 241 242 // Core taxonomies, non-post object types 242 // Core taxonomies, non-post object types. 243 243 $this->assertFalse( register_taxonomy_for_object_type( 'category', 'user' ) ); 244 244 $this->assertFalse( unregister_taxonomy_for_object_type( 'category', 'user' ) ); 245 245 246 // Non-core taxonomy, core post type 246 // Non-core taxonomy, core post type. 247 247 $this->assertTrue( unregister_taxonomy_for_object_type( $tax, 'post' ) ); 248 248 $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'post' ) ); 249 249 $this->assertTrue( register_taxonomy_for_object_type( $tax, 'post' ) ); 250 250 251 // Non-core taxonomy, non-core post type 251 // Non-core taxonomy, non-core post type. 252 252 $this->assertTrue( register_taxonomy_for_object_type( $tax, $post_type ) ); 253 253 $this->assertTrue( unregister_taxonomy_for_object_type( $tax, $post_type ) ); … … 255 255 $this->assertTrue( register_taxonomy_for_object_type( $tax, $post_type ) ); 256 256 257 // Non-core taxonomies, non-post object types 257 // Non-core taxonomies, non-post object types. 258 258 $this->assertFalse( register_taxonomy_for_object_type( $tax, 'user' ) ); 259 259 $this->assertFalse( unregister_taxonomy_for_object_type( $tax, 'user' ) ); … … 397 397 $post = self::factory()->post->create_and_get(); 398 398 399 // in_category() returns false when first parameter is empty() 399 // in_category() returns false when first parameter is empty(). 400 400 $this->assertFalse( in_category( '', $post ) ); 401 401 $this->assertFalse( in_category( false, $post ) ); 402 402 $this->assertFalse( in_category( null, $post ) ); 403 403 404 // Test expected behavior of in_category() 404 // Test expected behavior of in_category(). 405 405 $term = wp_insert_term( 'Test', 'category' ); 406 406 wp_set_object_terms( $post->ID, $term['term_id'], 'category' ); … … 948 948 'tax_input' => array( 949 949 $taxonomy_name => array( 950 (string) $term_id, // Cast term_id as string to match what s sent in WP Admin.950 (string) $term_id, // Cast term_id as string to match what's sent in WP Admin. 951 951 ), 952 952 ),
Note: See TracChangeset
for help on using the changeset viewer.