diff --git a/tests/phpunit/tests/term/isTermPubliclyViewable.php b/tests/phpunit/tests/term/isTermPubliclyViewable.php new file mode 100644 index 0000000000..a174b8eec5 --- /dev/null +++ b/tests/phpunit/tests/term/isTermPubliclyViewable.php @@ -0,0 +1,56 @@ +assertFalse( is_term_publicly_viewable( 123 ) ); + } + + /** + * Unit tests for is_term_publicly_viewable(). + * + * @dataProvider data_is_term_publicly_viewable + * @ticket 56215 + * + * @param string $taxonomy The taxonomy name. + * @param bool $expected The expected result of the function call. + */ + public function test_is_term_publicly_viewable( $taxonomy, $expected ) { + $term_id = $this->factory()->term->create( + array( + 'taxonomy' => $taxonomy, + ) + ); + + $this->assertSame( $expected, is_term_publicly_viewable( $term_id ) ); + } + + /** + * Data provider for test_is_term_publicly_viewable(). + * + * return array[] { + * @type string $taxonomy The taxonomy. + * @type bool $expected The expected result of the function call. + * } + */ + public function data_is_term_publicly_viewable() { + return array( + array( 'category', true ), + array( 'post_tag', true ), + array( 'post_format', true ), + + array( 'nav_menu', false ), + array( 'wp_theme', false ), + array( 'wp_template_part_area', false ), + ); + } +}