Add tests for is_post_type_viewable()
.
See #35609. git-svn-id: https://develop.svn.wordpress.org/trunk@36401 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
72f40494de
commit
81d3d79c1f
74
tests/phpunit/tests/post/isPostTypeViewable.php
Normal file
74
tests/phpunit/tests/post/isPostTypeViewable.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @group post
|
||||
*/
|
||||
class Tests_Post_IsPostTypeViewable extends WP_UnitTestCase {
|
||||
public function test_should_return_false_for_non_publicly_queryable_types() {
|
||||
register_post_type( 'wptests_pt', array(
|
||||
'publicly_queryable' => false,
|
||||
'_builtin' => false,
|
||||
'public' => true,
|
||||
) );
|
||||
|
||||
$pt = get_post_type_object( 'wptests_pt' );
|
||||
|
||||
$this->assertFalse( is_post_type_viewable( $pt ) );
|
||||
}
|
||||
|
||||
public function test_should_return_true_for_publicly_queryable_types() {
|
||||
register_post_type( 'wptests_pt', array(
|
||||
'publicly_queryable' => true,
|
||||
'_builtin' => false,
|
||||
'public' => false,
|
||||
) );
|
||||
|
||||
$pt = get_post_type_object( 'wptests_pt' );
|
||||
|
||||
$this->assertTrue( is_post_type_viewable( $pt ) );
|
||||
}
|
||||
|
||||
public function test_should_return_false_for_builtin_nonpublic_types() {
|
||||
register_post_type( 'wptests_pt', array(
|
||||
'publicly_queryable' => false,
|
||||
'_builtin' => true,
|
||||
'public' => false,
|
||||
) );
|
||||
|
||||
$pt = get_post_type_object( 'wptests_pt' );
|
||||
|
||||
$this->assertFalse( is_post_type_viewable( $pt ) );
|
||||
}
|
||||
|
||||
public function test_should_return_false_for_nonbuiltin_public_types() {
|
||||
register_post_type( 'wptests_pt', array(
|
||||
'publicly_queryable' => false,
|
||||
'_builtin' => false,
|
||||
'public' => true,
|
||||
) );
|
||||
|
||||
$pt = get_post_type_object( 'wptests_pt' );
|
||||
|
||||
$this->assertFalse( is_post_type_viewable( $pt ) );
|
||||
}
|
||||
|
||||
public function test_should_return_true_for_builtin_public_types() {
|
||||
register_post_type( 'wptests_pt', array(
|
||||
'publicly_queryable' => false,
|
||||
'_builtin' => true,
|
||||
'public' => true,
|
||||
) );
|
||||
|
||||
$pt = get_post_type_object( 'wptests_pt' );
|
||||
|
||||
$this->assertTrue( is_post_type_viewable( $pt ) );
|
||||
}
|
||||
|
||||
public function test_postpage_should_be_viewable() {
|
||||
$post = get_post_type_object( 'post' );
|
||||
$this->assertTrue( is_post_type_viewable( $post ) );
|
||||
|
||||
$page = get_post_type_object( 'page' );
|
||||
$this->assertTrue( is_post_type_viewable( $page ) );
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user