diff --git a/tests/phpunit/tests/category/wpListCategories.php b/tests/phpunit/tests/category/wpListCategories.php index dbd4cbb98d..646128641c 100644 --- a/tests/phpunit/tests/category/wpListCategories.php +++ b/tests/phpunit/tests/category/wpListCategories.php @@ -1,9 +1,50 @@ factory->category->create(); + + $found = wp_list_categories( array( + 'hide_empty' => false, + 'echo' => false, + ) ); + + $this->assertContains( 'class="cat-item cat-item-' . $c . '"', $found ); + } + + public function test_class_containing_current_cat() { + $c1 = $this->factory->category->create(); + $c2 = $this->factory->category->create(); + + $found = wp_list_categories( array( + 'hide_empty' => false, + 'echo' => false, + 'current_category' => $c2, + ) ); + + $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat[^"]*"/', $found ); + $this->assertRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat[^"]*"/', $found ); + } + + public function test_class_containing_current_cat_parent() { + $c1 = $this->factory->category->create(); + $c2 = $this->factory->category->create( array( + 'parent' => $c1, + ) ); + + $found = wp_list_categories( array( + 'hide_empty' => false, + 'echo' => false, + 'current_category' => $c2, + ) ); + + $this->assertRegExp( '/class="[^"]*cat-item-' . $c1 . '[^"]*current-cat-parent[^"]*"/', $found ); + $this->assertNotRegExp( '/class="[^"]*cat-item-' . $c2 . '[^"]*current-cat-parent[^"]*"/', $found ); + } + /** * @ticket 16792 */