WordPress.org

Make WordPress Core

Changeset 31301


Ignore:
Timestamp:
01/30/2015 01:39:31 AM (7 years ago)
Author:
boonebgorges
Message:

Add unit tests for 'show_option_all' behavior of wp_list_categories().

See #21881.

File:
1 edited

Legend:

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

    r31026 r31301  
    7171    }
    7272
     73    public function test_show_option_all_link_should_go_to_home_page_when_show_on_front_is_false() {
     74        $cats = $this->factory->category->create_many( 2 );
     75
     76        $found = wp_list_categories( array(
     77            'echo' => false,
     78            'show_option_all' => 'All',
     79            'hide_empty' => false,
     80            'taxonomy' => 'category',
     81        ) );
     82
     83        $this->assertContains( "<li class='cat-item-all'><a href='" . home_url( '/' ) . "'>All</a></li>", $found );
     84    }
     85
     86    public function test_show_option_all_link_should_respect_page_for_posts() {
     87        $cats = $this->factory->category->create_many( 2 );
     88        $p = $this->factory->post->create( array( 'post_type' => 'page' ) );
     89
     90        update_option( 'show_on_front', 'page' );
     91        update_option( 'page_for_posts', $p );
     92
     93        $found = wp_list_categories( array(
     94            'echo' => false,
     95            'show_option_all' => 'All',
     96            'hide_empty' => false,
     97            'taxonomy' => 'category',
     98        ) );
     99
     100        $this->assertContains( "<li class='cat-item-all'><a href='" . get_permalink( $p ) . "'>All</a></li>", $found );
     101    }
     102
    73103    public function list_cats_callback( $cat ) {
    74104        if ( 'Test Cat 1' === $cat ) {
Note: See TracChangeset for help on using the changeset viewer.