From 9f8e5d3c175938589af5d92641d725efd8f11b7e Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 30 Jan 2015 01:39:31 +0000 Subject: [PATCH] Add unit tests for 'show_option_all' behavior of `wp_list_categories()`. See #21881. git-svn-id: https://develop.svn.wordpress.org/trunk@31301 602fd350-edb4-49c9-b593-d223f7449a82 --- .../tests/category/wpListCategories.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/phpunit/tests/category/wpListCategories.php b/tests/phpunit/tests/category/wpListCategories.php index 646128641c..55af2f484e 100644 --- a/tests/phpunit/tests/category/wpListCategories.php +++ b/tests/phpunit/tests/category/wpListCategories.php @@ -70,6 +70,36 @@ class Tests_Category_WpListCategories extends WP_UnitTestCase { $this->assertNotContains( 'Test Cat 1', $found ); } + public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() { + $cats = $this->factory->category->create_many( 2 ); + + $found = wp_list_categories( array( + 'echo' => false, + 'show_option_all' => 'All', + 'hide_empty' => false, + 'taxonomy' => 'category', + ) ); + + $this->assertContains( "
  • All
  • ", $found ); + } + + public function test_show_option_all_link_should_respect_page_for_posts() { + $cats = $this->factory->category->create_many( 2 ); + $p = $this->factory->post->create( array( 'post_type' => 'page' ) ); + + update_option( 'show_on_front', 'page' ); + update_option( 'page_for_posts', $p ); + + $found = wp_list_categories( array( + 'echo' => false, + 'show_option_all' => 'All', + 'hide_empty' => false, + 'taxonomy' => 'category', + ) ); + + $this->assertContains( "
  • All
  • ", $found ); + } + public function list_cats_callback( $cat ) { if ( 'Test Cat 1' === $cat ) { return '';