WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/29/2015 05:10:10 AM (5 years ago)
Author:
wonderboymusic
Message:

Allow wp_get_archives() to accept post_type as an arg.

Adds unit test.

Fixes #21596.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/functions/getArchives.php

    r28960 r34686  
    8989        $this->assertEquals( $expected['order_desc'], trim( wp_get_archives( array( 'echo' => false, 'order' => 'DESC' ) ) ) );
    9090    }
     91
     92    /**
     93     * @ticket 21596
     94     */
     95    function test_wp_get_archives_post_type() {
     96        register_post_type( 'taco', array( 'public' => true ) );
     97
     98        $this->factory->post->create( array(
     99            'post_type' => 'taco',
     100            'post_author' => '1',
     101            'post_date' => '2014-10-23 19:34:42'
     102        ) );
     103
     104        $oct_url = esc_url( add_query_arg( 'post_type', 'taco', get_month_link( 2014, 10 ) ) );
     105        $expected = "<li><a href='{$oct_url}'>October 2014</a></li>";
     106        $archives = wp_get_archives( array( 'echo' => false, 'post_type' => 'taco' ) );
     107        $this->assertEquals( $expected, trim( $archives ) );
     108    }
    91109}
Note: See TracChangeset for help on using the changeset viewer.