Index: tests/phpunit/tests/category/listCategories.php
===================================================================
--- tests/phpunit/tests/category/listCategories.php	(revision 0)
+++ tests/phpunit/tests/category/listCategories.php	(revision 0)
@@ -0,0 +1,258 @@
+<?php
+
+class Tests_List_Categories extends WP_UnitTestCase {
+
+	protected $parent_id;
+	protected $news_id;
+
+	function setup() {
+		parent::setUp();
+		$this->parent_id = $this->factory->category->create( array( 'name' => 'Parent', 'slug' => 'parent' ) );
+		$this->news_id = $this->factory->category->create( array( 'name' => 'News', 'slug' => 'news' ) );
+
+	}
+
+	function test_wp_list_categories_default() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0 );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_show_option_all() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'show_option_all' => "All Categories" );
+		$expected = '<li class="categories">Categories<ul><li class=\'cat-item-all\'><a href=\'http://example.org/\'>All Categories</a></li>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_show_option_none() {
+		$args = array( 'echo'=> 0, 'show_option_none' => 'Nothing Found...' );
+		$expected = '<li class="categories">Categories<ul><li class="cat-item-none">Nothing Found...</li></ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_orderby() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'orderby' => 'ID'  );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_order() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'orderby' => 'ID', 'order' => 'DESC'  );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_style() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'style' => 'none' );
+		$expected = '	<a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a><br />
+	<a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a><br />
+	<a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a><br />
+';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_show_count() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'show_count' => 1 );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a> (0)
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a> (0)
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a> (0)
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_hide_empty() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 1 );
+		$expected = '<li class="categories">Categories<ul><li class="cat-item-none">No categories</li></ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_use_desc_for_title() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'use_desc_for_title' => 0 );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="View all posts filed under News">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="View all posts filed under Parent">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_child_of() {
+		$child_id = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $this->parent_id ) );
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'child_of' => $this->parent_id );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $child_id . '"><a href="' . get_category_link( $child_id ) . '" title="Term description 3">Child</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_feed() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'feed' => 'Feed' );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a> (<a href="http://example.org/?feed=rss2&#038;cat=' . $this->news_id . '" title="Feed">Feed</a>)
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a> (<a href="http://example.org/?feed=rss2&#038;cat=' . $this->parent_id . '" title="Feed">Feed</a>)
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a> (<a href="http://example.org/?feed=rss2&#038;cat=1" title="Feed">Feed</a>)
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_feed_type() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'feed' => 'Feed', 'feed_type' => 'rss'  );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a> (<a href="http://example.org/?feed=rss&#038;cat=' . $this->news_id . '" title="Feed">Feed</a>)
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a> (<a href="http://example.org/?feed=rss&#038;cat=' . $this->parent_id . '" title="Feed">Feed</a>)
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a> (<a href="http://example.org/?feed=rss&#038;cat=1" title="Feed">Feed</a>)
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_feed_image() {
+		$args = array( 'echo' => 0, 'hide_empty' => 0, 'feed_image' => 'http://domain.com/feed-image.png', 'feed' => 'rss' );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a> <a href="http://example.org/?feed=rss2&#038;cat=' . $this->news_id . '" title="rss"><img src=\'http://domain.com/feed-image.png\' alt="rss" title="rss" /></a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a> <a href="http://example.org/?feed=rss2&#038;cat=' . $this->parent_id . '" title="rss"><img src=\'http://domain.com/feed-image.png\' alt="rss" title="rss" /></a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a> <a href="http://example.org/?feed=rss2&#038;cat=1" title="rss"><img src=\'http://domain.com/feed-image.png\' alt="rss" title="rss" /></a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_exclude() {
+		$args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude' => $this->parent_id );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	/**
+	 * @ticket 12981
+	 */
+
+	function test_wp_list_categories_exclude_tree() {
+		$child_id = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $this->parent_id ) );
+		$args = array( 'echo' => 0, 'hide_empty' => 0, 'exclude_tree' => $this->parent_id );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_current_category() {
+		$args = array( 'echo' => 0, 'hide_empty' => 0, 'current_category' => $this->parent_id );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . ' current-cat"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_hierarchical() {
+		$child_id = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => 36 ) );
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'hierarchical' => 0 );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $child_id . '"><a href="' . get_category_link( $child_id ) . '" title="Term description 3">Child</a>
+</li>
+	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_title_li() {
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'title_li' => 'My Categories' );
+		$expected = '<li class="categories">My Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_echo() {
+		$args = array( 'echo'=> 1 );
+		$expected = '<li class="categories">Categories<ul><li class="cat-item-none">No categories</li></ul></li>';
+		ob_start();
+		wp_list_categories( $args );
+		$actual = ob_get_clean();
+		$this->AssertEquals( $expected, $actual );
+	}
+
+	function test_wp_list_categories_depth() {
+		$child_id = $this->factory->category->create( array( 'name' => 'Child', 'slug' => 'child', 'parent' => $this->parent_id ) );
+		$args = array( 'echo'=> 0, 'hide_empty' => 0, 'depth' => 1 );
+		$expected = '<li class="categories">Categories<ul>	<li class="cat-item cat-item-' . $this->news_id . '"><a href="' . get_category_link( $this->news_id ) . '" title="Term description 2">News</a>
+</li>
+	<li class="cat-item cat-item-' . $this->parent_id . '"><a href="' . get_category_link( $this->parent_id ) . '" title="Term description 1">Parent</a>
+</li>
+	<li class="cat-item cat-item-1"><a href="' . get_category_link( 1 ) . '" title="View all posts filed under Uncategorized">Uncategorized</a>
+</li>
+</ul></li>';
+		$actual = wp_list_categories( $args );
+		$this->AssertEquals( $expected, $actual );
+	}
+
+}
