Make WordPress Core


Ignore:
Timestamp:
09/02/2018 10:08:05 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Taxonomy: Make sure wp_list_categories() correctly outputs term name of 0.

Props joyously, SergeyBiryukov.
Fixes #44872.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/category/wpListCategories.php

    r43571 r43605  
    104104    }
    105105
     106    public function list_cats_callback( $cat ) {
     107        if ( 'Test Cat 1' === $cat ) {
     108            return '';
     109        }
     110
     111        return $cat;
     112    }
     113
     114    /**
     115     * @ticket 44872
     116     */
     117    public function test_should_create_element_when_cat_name_is_zero() {
     118        $c = self::factory()->category->create(
     119            array(
     120                'name' => '0',
     121            )
     122        );
     123
     124        $found = wp_list_categories(
     125            array(
     126                'hide_empty' => false,
     127                'echo'       => false,
     128            )
     129        );
     130
     131        $this->assertContains( "cat-item-$c", $found );
     132        $this->assertContains( '0', $found );
     133    }
     134
    106135    public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() {
    107136        $cats = self::factory()->category->create_many( 2 );
     
    248277    }
    249278
    250     public function list_cats_callback( $cat ) {
    251         if ( 'Test Cat 1' === $cat ) {
    252             return '';
    253         }
    254 
    255         return $cat;
    256     }
    257 
    258279    /**
    259280     * @ticket 33460
Note: See TracChangeset for help on using the changeset viewer.