Add tests for `wp_list_categories()` CSS class generation.

See #16497.

git-svn-id: https://develop.svn.wordpress.org/trunk@31026 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges 2015-01-03 02:22:54 +00:00
parent fd8b7faff6
commit 3da394f499
1 changed files with 42 additions and 1 deletions

View File

@ -1,9 +1,50 @@
<?php
/**
* @group category
* @group taxonomy
*/
class Tests_Category_WpListCategories extends WP_UnitTestCase {
public function test_class() {
$c = $this->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
*/