mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Posts: Introduce get_post_types_by_support().
Similar to `get_post_types()`, this new function returns a list of post type names that support a specific feature. Props wpsmith, barryceelen, swissspidy. Fixes #34010. git-svn-id: https://develop.svn.wordpress.org/trunk@36652 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -379,4 +379,53 @@ class Tests_Post_Types extends WP_UnitTestCase {
|
||||
|
||||
$this->assertFalse( post_type_exists( 'foo' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34010
|
||||
*/
|
||||
public function test_get_post_types_by_support_single_feature() {
|
||||
$this->assertContains( 'post', get_post_types_by_support( 'title' ) );
|
||||
$this->assertContains( 'page', get_post_types_by_support( 'title' ) );
|
||||
$this->assertContains( 'attachment', get_post_types_by_support( 'title' ) );
|
||||
$this->assertContains( 'nav_menu_item', get_post_types_by_support( 'title' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34010
|
||||
*/
|
||||
public function test_get_post_types_by_support_multiple_features() {
|
||||
$this->assertContains( 'post', get_post_types_by_support( array( 'thumbnail', 'author' ) ) );
|
||||
$this->assertContains( 'page', get_post_types_by_support( array( 'thumbnail', 'author' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34010
|
||||
*/
|
||||
public function test_get_post_types_by_support_or_operator() {
|
||||
$this->assertContains( 'post', get_post_types_by_support( array( 'post-formats', 'page-attributes' ), 'or' ) );
|
||||
$this->assertContains( 'page', get_post_types_by_support( array( 'post-formats', 'page-attributes' ), 'or' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34010
|
||||
*/
|
||||
public function test_get_post_types_by_support_not_operator() {
|
||||
$this->assertContains( 'attachment', get_post_types_by_support( array( 'thumbnail' ), 'not' ) );
|
||||
$this->assertContains( 'revision', get_post_types_by_support( array( 'thumbnail' ), 'not' ) );
|
||||
$this->assertContains( 'nav_menu_item', get_post_types_by_support( array( 'thumbnail' ), 'not' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34010
|
||||
*/
|
||||
public function test_get_post_types_by_support_excluding_features() {
|
||||
$this->assertEqualSets( array(), get_post_types_by_support( array( 'post-formats', 'page-attributes' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34010
|
||||
*/
|
||||
public function test_get_post_types_by_support_non_existant_feature() {
|
||||
$this->assertEqualSets( array(), get_post_types_by_support( 'somefeature' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user