| | 85 | // make up a new taxonomy name, and ensure it's unused |
| | 86 | $tax = rand_str(); |
| | 87 | $this->assertFalse( taxonomy_exists( $tax . '_taxonomy' ) ); |
| | 88 | |
| | 89 | // Register the new taxonomy |
| | 90 | $args = array( $tax . '_taxonomy' => true, 'hierarchical' => 0, 'rewrite' => array( 'slug' ), ); |
| | 91 | register_taxonomy( $tax . '_taxonomy', array( $tax . '_post_type' ), $args ); |
| | 92 | $this->assertTrue( taxonomy_exists( $tax . '_taxonomy' ) ); |
| | 93 | |
| | 94 | // Get the taxonomy using the name as the key |
| | 95 | // If ticket 20929 isn't fixed, this will produce a notice |
| | 96 | // If you're not running with -d, force notices on |
| | 97 | if ( !defined( 'WP_DEBUG' ) || !WP_DEBUG ) { |
| | 98 | $err = error_reporting(); |
| | 99 | error_reporting( $err | E_NOTICE ); |
| | 100 | } |
| | 101 | $new_tax = get_taxonomies( array( $tax . '_taxonomy' => true ) ); |
| | 102 | if ( !defined( 'WP_DEBUG' ) || !WP_DEBUG ) { |
| | 103 | error_reporting( $err ); |
| | 104 | } |
| | 105 | |
| | 106 | // Get back exactly 1 match |
| | 107 | $this->assertEquals( 1, count( $new_tax ) ); |
| | 108 | |
| | 109 | // Key and val should match the random tax name |
| | 110 | list($key, $val) = each( $new_tax ); |
| | 111 | $this->assertEquals( $tax . '_taxonomy', $key ); |
| | 112 | $this->assertEquals( $tax . '_taxonomy', $val ); |
| | 113 | |
| | 114 | // clean up |
| | 115 | unset( $GLOBALS['wp_taxonomies'][$tax . '_taxnomy'] ); |
| | 116 | } |
| | 117 | |