diff --git a/tests/phpunit/tests/post/isPostTypeViewable.php b/tests/phpunit/tests/post/isPostTypeViewable.php new file mode 100644 index 0000000000..17b3f7de7b --- /dev/null +++ b/tests/phpunit/tests/post/isPostTypeViewable.php @@ -0,0 +1,74 @@ + 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 ) ); + } +}