mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Taxonomy: Introduce is_taxonomy_viewable().
This utility function allows for easy detection whether terms for a taxonomy are considered publicly viewable. Props andizer. Fixes #44466. git-svn-id: https://develop.svn.wordpress.org/trunk@43386 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group taxonomy
|
||||
*/
|
||||
class Tests_Taxonomy_IsTaxonomyViewable extends WP_UnitTestCase {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
register_post_type( 'wptests_pt' );
|
||||
register_taxonomy( 'wptests_tax_viewable', 'wptests_pt', array( 'publicly_queryable' => true ) );
|
||||
register_taxonomy( 'wptests_tax_non_viewable', 'wptests_pt', array( 'publicly_queryable' => false ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44466
|
||||
*/
|
||||
public function test_is_taxonomy_viewable_for_querable_taxonomy() {
|
||||
$this->assertTrue( is_taxonomy_viewable( 'wptests_tax_viewable' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44466
|
||||
*/
|
||||
public function test_is_taxonomy_viewable_for_non_querable_taxonomy() {
|
||||
$this->assertFalse( is_taxonomy_viewable( 'wptests_tax_non_viewable' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44466
|
||||
*/
|
||||
public function test_is_taxonomy_viewable_for_non_existing_taxonomy() {
|
||||
$this->assertFalse( is_taxonomy_viewable( 'wptests_tax_non_existing' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44466
|
||||
*/
|
||||
public function test_is_taxonomy_viewable_with_object_given() {
|
||||
$taxonomy = get_taxonomy( 'wptests_tax_viewable' );
|
||||
|
||||
$this->assertTrue( is_taxonomy_viewable( $taxonomy ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user