WordPress.org

Make WordPress Core

Changeset 1134 in tests


Ignore:
Timestamp:
11/14/12 20:59:17 (20 months ago)
Author:
nbachiyski
Message:

Reflect class rename

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/export/class-wp-wxr-export.php

    r1131 r1134  
    22 
    33/** 
    4  * Test WP_WXR_Export class 
     4 * Test WP_Export_Query class 
    55 * 
    66 * @group export 
    77 * @ticket 22435 
    88 */ 
    9 class Test_WP_WXR_Export extends WP_UnitTestCase { 
    10     function test_WP_WXR_Export_should_be_initialized_with_an_array() { 
    11         $export = new WP_WXR_Export( array( 'author' => 'all' ) ); 
     9class Test_WP_Export_Query extends WP_UnitTestCase { 
     10    function test_WP_Export_Query_should_be_initialized_with_an_array() { 
     11        $export = new WP_Export_Query( array( 'author' => 'all' ) ); 
    1212        $this->assertTrue( (bool) $export ); 
    1313    } 
    1414 
    15     function test_WP_WXR_Export_should_use_post_ids_if_passed() { 
    16         $export = new WP_WXR_Export( array( 'post_ids' => array( 1, 2, 3 ) ) ); 
     15    function test_WP_Export_Query_should_use_post_ids_if_passed() { 
     16        $export = new WP_Export_Query( array( 'post_ids' => array( 1, 2, 3 ) ) ); 
    1717        $this->assertEquals( array( 1, 2, 3 ), $export->post_ids() ); 
    1818    } 
    1919 
    20     function test_WP_WXR_Export_should_filter_all_posts_if_all_arg_is_true() { 
     20    function test_WP_Export_Query_should_filter_all_posts_if_all_arg_is_true() { 
    2121        $post_id = $this->factory->post->create(); 
    22         $export = new WP_WXR_Export(); 
     22        $export = new WP_Export_Query(); 
    2323        $this->assertEquals( array( $post_id ), $export->post_ids() ); 
    2424    } 
    2525 
    26     function test_WP_WXR_Export_should_filter_all_posts_if_no_args_passed() { 
     26    function test_WP_Export_Query_should_filter_all_posts_if_no_args_passed() { 
    2727        $post_id = $this->factory->post->create(); 
    28         $export = new WP_WXR_Export(); 
     28        $export = new WP_Export_Query(); 
    2929        $this->assertEquals( array( $post_id ), $export->post_ids() ); 
    3030    } 
    3131 
    32     function test_WP_WXR_Export_should_not_export_anything_if_post_type_arg_is_set_to_non_existing_post_type() { 
     32    function test_WP_Export_Query_should_not_export_anything_if_post_type_arg_is_set_to_non_existing_post_type() { 
    3333        $post_id = $this->factory->post->create(); 
    34         $export = new WP_WXR_Export( array( 'post_type' => 'baba' ) ); 
     34        $export = new WP_Export_Query( array( 'post_type' => 'baba' ) ); 
    3535        $this->assertEquals( array(), $export->post_ids() ); 
    3636    } 
    3737 
    38     function test_WP_WXR_Export_should_filter_only_posts_with_a_certain_post_type_if_the_post_type_arg_is_set() { 
     38    function test_WP_Export_Query_should_filter_only_posts_with_a_certain_post_type_if_the_post_type_arg_is_set() { 
    3939        register_post_type( 'baba' ); 
    4040        $post_id = $this->factory->post->create( array( 'post_type' => 'baba' ) ); 
    4141        $_       = $this->factory->post->create( array( 'post_type' => 'dyado' ) ); 
    42         $export = new WP_WXR_Export( array( 'post_type' => 'baba' ) ); 
     42        $export = new WP_Export_Query( array( 'post_type' => 'baba' ) ); 
    4343        $this->assertEquals( array( $post_id ), $export->post_ids() ); 
    4444        _unregister_post_type( 'baba' ); 
    4545    } 
    4646 
    47     function test_WP_WXR_Export_should_not_export_post_types_with_can_export_set_to_false() { 
     47    function test_WP_Export_Query_should_not_export_post_types_with_can_export_set_to_false() { 
    4848        register_post_type( 'non-exportable', array( 'can_export' => false ) ); 
    4949        register_post_type( 'exportable', array( 'can_export' => true ) ); 
    5050        $non_exportable_post_id = $this->factory->post->create( array( 'post_type' => 'non-exportable' ) ); 
    5151        $exportable_post_id = $this->factory->post->create( array( 'post_type' => 'exportable' ) ); 
    52         $export = new WP_WXR_Export(); 
     52        $export = new WP_Export_Query(); 
    5353        $this->assertEquals( array( $exportable_post_id ), $export->post_ids() ); 
    5454        _unregister_post_type( 'non-exportable' ); 
     
    5656    } 
    5757 
    58     function test_WP_WXR_Export_should_not_export_auto_drafts_by_default() { 
     58    function test_WP_Export_Query_should_not_export_auto_drafts_by_default() { 
    5959        $post_id = $this->factory->post->create( array( 'post_status' => 'auto-draft' ) ); 
    60         $export = new WP_WXR_Export(); 
     60        $export = new WP_Export_Query(); 
    6161        $this->assertEquals( array(), $export->post_ids() ); 
    6262    } 
    6363 
    64     function test_WP_WXR_Export_should_filter_only_posts_with_certain_status_if_status_arg_is_set() { 
     64    function test_WP_Export_Query_should_filter_only_posts_with_certain_status_if_status_arg_is_set() { 
    6565        $post_id_baba = $this->factory->post->create( array( 'post_status' => 'baba' ) ); 
    6666        $post_id_dudu = $this->factory->post->create( array( 'post_status' => 'dudu' ) ); 
    67         $export = new WP_WXR_Export( array( 'status' => 'baba' ) ); 
     67        $export = new WP_Export_Query( array( 'status' => 'baba' ) ); 
    6868        $this->assertEquals( array( $post_id_baba ), $export->post_ids() ); 
    6969    } 
    7070 
    71     function test_WP_WXR_Export_should_filter_only_posts_with_certain_author_id_if_status_arg_is_a_number() { 
     71    function test_WP_Export_Query_should_filter_only_posts_with_certain_author_id_if_status_arg_is_a_number() { 
    7272        $user_id = $this->factory->user->create(); 
    7373        $post_by_user = $this->factory->post->create( array( 'post_author' => $user_id ) ); 
    7474        $other_post = $this->factory->post->create( array( 'post_author' => $user_id + 1 ) ); 
    75         $export = new WP_WXR_Export( array( 'author' => $user_id ) ); 
     75        $export = new WP_Export_Query( array( 'author' => $user_id ) ); 
    7676        $this->assertEquals( array( $post_by_user ), $export->post_ids() ); 
    7777    } 
    7878 
    79     function test_WP_WXR_Export_should_filter_only_posts_with_certain_author_name_if_status_arg_is_a_username() { 
     79    function test_WP_Export_Query_should_filter_only_posts_with_certain_author_name_if_status_arg_is_a_username() { 
    8080        $user = $this->factory->user->create_and_get( array( 'user_login' => 'baba' ) ); 
    8181        $post_by_user = $this->factory->post->create( array( 'post_author' => $user->ID ) ); 
    8282        $other_post = $this->factory->post->create( array( 'post_author' => $user->ID + 1 ) ); 
    83         $export = new WP_WXR_Export( array( 'author' => 'baba' ) ); 
     83        $export = new WP_Export_Query( array( 'author' => 'baba' ) ); 
    8484        $this->assertEquals( array( $post_by_user ), $export->post_ids() ); 
    8585    } 
    8686 
    87     function test_WP_WXR_Export_should_filter_only_posts_with_certain_author_object_if_author_is_an_object_with_ID_member_variable() { 
     87    function test_WP_Export_Query_should_filter_only_posts_with_certain_author_object_if_author_is_an_object_with_ID_member_variable() { 
    8888        $user = $this->factory->user->create_and_get(); 
    8989        $post_by_user = $this->factory->post->create( array( 'post_author' => $user->ID ) ); 
    9090        $other_post = $this->factory->post->create( array( 'post_author' => $user->ID + 1 ) ); 
    91         $export = new WP_WXR_Export( array( 'author' => $user ) ); 
     91        $export = new WP_Export_Query( array( 'author' => $user ) ); 
    9292        $this->assertEquals( array( $post_by_user ), $export->post_ids() ); 
    9393    } 
    9494 
    95     function test_WP_WXR_Export_should_filter_only_posts_after_certain_start_date_if_start_date_arg_is_passed() { 
     95    function test_WP_Export_Query_should_filter_only_posts_after_certain_start_date_if_start_date_arg_is_passed() { 
    9696        $post_before = $this->factory->post->create( array( 'post_date' => '2012-11-10 23:59:59' ) ); 
    9797        $post_after = $this->factory->post->create( array( 'post_date' => '2012-11-11 00:00:00' ) ); 
    98         $export = new WP_WXR_Export( array( 'start_date' => '2012-11-11' ) ); 
     98        $export = new WP_Export_Query( array( 'start_date' => '2012-11-11' ) ); 
    9999        $this->assertEquals( array( $post_after ), $export->post_ids() ); 
    100100    } 
    101101 
    102     function test_WP_WXR_Export_should_filter_only_posts_after_certain_end_date_if_end_date_arg_is_passed() { 
     102    function test_WP_Export_Query_should_filter_only_posts_after_certain_end_date_if_end_date_arg_is_passed() { 
    103103        $post_before = $this->factory->post->create( array( 'post_date' => '2012-11-10 23:59:59' ) ); 
    104104        $post_after = $this->factory->post->create( array( 'post_date' => '2012-11-11 00:00:00' ) ); 
    105         $export = new WP_WXR_Export( array( 'end_date' => '2012-11-10' ) ); 
     105        $export = new WP_Export_Query( array( 'end_date' => '2012-11-10' ) ); 
    106106        $this->assertEquals( array( $post_before ), $export->post_ids() ); 
    107107    } 
    108108 
    109     function test_WP_WXR_Export_should_filter_only_posts_with_certain_category_if_category_arg_is_passed() { 
     109    function test_WP_Export_Query_should_filter_only_posts_with_certain_category_if_category_arg_is_passed() { 
    110110        $category_id = $this->factory->category->create( array( 'name' => 'baba' ) ); 
    111111        $post_with_category = $this->factory->post->create( array( 'post_category' => array( $category_id ) ) ); 
    112112        $post_without = $this->factory->post->create(); 
    113         $export = new WP_WXR_Export( array( 'post_type' => 'post', 'category' => 'baba' ) ); 
     113        $export = new WP_Export_Query( array( 'post_type' => 'post', 'category' => 'baba' ) ); 
    114114        $this->assertEquals( array( $post_with_category ), $export->post_ids() ); 
    115115    } 
    116116 
    117     function test_WP_WXR_Export_should_filter_only_posts_with_certain_category_id_if_category_arg_is_passed() { 
     117    function test_WP_Export_Query_should_filter_only_posts_with_certain_category_id_if_category_arg_is_passed() { 
    118118        $category_id = $this->factory->category->create( array( 'name' => 'baba' ) ); 
    119119        $post_with_category = $this->factory->post->create( array( 'post_category' => array( $category_id ) ) ); 
    120120        $post_without = $this->factory->post->create(); 
    121         $export = new WP_WXR_Export( array( 'post_type' => 'post', 'category' => $category_id ) ); 
     121        $export = new WP_Export_Query( array( 'post_type' => 'post', 'category' => $category_id ) ); 
    122122        $this->assertEquals( array( $post_with_category ), $export->post_ids() ); 
    123123    } 
    124124 
    125     function test_WP_WXR_Export_should_filter_posts_by_category_only_for_post_post_type() { 
     125    function test_WP_Export_Query_should_filter_posts_by_category_only_for_post_post_type() { 
    126126        $category_id = $this->factory->category->create( array( 'name' => 'baba' ) ); 
    127127        $post_with_category = $this->factory->post->create( array( 'post_category' => array( $category_id ) ) ); 
    128128        $post_without = $this->factory->post->create(); 
    129129        $different_post_type = $this->factory->post->create( array( 'post_type' => 'page' ) ); 
    130         $export = new WP_WXR_Export( array( 'category' => $category_id ) ); 
     130        $export = new WP_Export_Query( array( 'category' => $category_id ) ); 
    131131        $this->assertEqualSets( array( $post_with_category, $post_without, $different_post_type ), $export->post_ids() ); 
    132132    } 
    133133 
    134     function test_WP_WXR_Export_should_include_attachments_of_posts_if_we_are_filtering_only_some_post_types() { 
     134    function test_WP_Export_Query_should_include_attachments_of_posts_if_we_are_filtering_only_some_post_types() { 
    135135        register_post_type( 'baba' ); 
    136136        $post_id = $this->factory->post->create( array( 'post_type' => 'baba' ) ); 
    137137        $attachment_post_id = $this->factory->post->create( array( 'post_type' => 'attachment', 'post_parent' => $post_id ) ); 
    138         $export = new WP_WXR_Export( array( 'post_type' => 'baba' ) ); 
     138        $export = new WP_Export_Query( array( 'post_type' => 'baba' ) ); 
    139139        $this->assertEquals( array( $post_id, $attachment_post_id ), $export->post_ids() ); 
    140140        _unregister_post_type( 'baba' ); 
     
    142142 
    143143    function test_export_xml_using_writer_class_returns_wp_error_if_the_writer_throws_wxr_exception() { 
    144         $export = new WP_WXR_Export(); 
     144        $export = new WP_Export_Query(); 
    145145        $this->assertTrue( is_wp_error( $export->export_xml_using_writer_class( 'Test_WP_WXR_Stub_Writer_Throws_WXR_Exception' ) ) ); 
    146146    } 
     
    148148    function test_export_xml_using_writer_class_passes_the_exception_if_the_writer_throws_other_exception() { 
    149149        $this->setExpectedException( 'Exception' ); 
    150         $export = new WP_WXR_Export(); 
     150        $export = new WP_Export_Query(); 
    151151        $export->export_xml_using_writer_class( 'Test_WP_WXR_Stub_Writer_Throws_Other_Exception' ); 
    152152    } 
     
    155155        $user_id = $this->factory->user->create(); 
    156156        $this->factory->post->create( array( 'post_author' => $user_id ) ); 
    157         $export = new WP_WXR_Export(); 
     157        $export = new WP_Export_Query(); 
    158158        $authors = $export->authors(); 
    159159        $this->assertEquals( 1, count( $authors ) ); 
     
    163163    function test_authors_should_skip_non_existing_authors() { 
    164164        $this->factory->post->create( array( 'post_author' => 11 ) ); 
    165         $export = new WP_WXR_Export(); 
     165        $export = new WP_Export_Query(); 
    166166        $this->assertEquals( array(), $export->authors() ); 
    167167    } 
     
    170170        $user_id = $this->factory->user->create(); 
    171171        $this->factory->post->create( array( 'post_author' => $user_id, 'post_status' => 'auto-draft' ) ); 
    172         $export = new WP_WXR_Export(); 
     172        $export = new WP_Export_Query(); 
    173173        $this->assertEquals( array(), $export->authors() ); 
    174174    } 
     
    177177        $category_id = $this->factory->category->create( array( 'name' => 'baba' ) ); 
    178178        $other_category_id = $this->factory->category->create( array( 'name' => 'dyado' ) ); 
    179         $export = new WP_WXR_Export( array( 'post_type' => 'post', 'category' => $category_id ) ); 
     179        $export = new WP_Export_Query( array( 'post_type' => 'post', 'category' => $category_id ) ); 
    180180        $this->assertEquals( 1, count( $export->categories() ) ); 
    181181    } 
     
    183183    function test_categories_should_return_no_categories_if_we_are_requesting_only_one_post_type() { 
    184184        $category_id = $this->factory->category->create(); 
    185         $export = new WP_WXR_Export( array( 'post_type' => 'post' ) ); 
     185        $export = new WP_Export_Query( array( 'post_type' => 'post' ) ); 
    186186        $this->assertEquals( array(), $export->categories() ); 
    187187    } 
     
    190190        $category_id = $this->factory->category->create(); 
    191191        $another_category_id = $this->factory->category->create(); 
    192         $export = new WP_WXR_Export(); 
     192        $export = new WP_Export_Query(); 
    193193        $this->assertEqualSets( array( 1, $category_id, $another_category_id ), self::get_term_ids( $export->categories() ) ); 
    194194    } 
     
    198198        $top_category_id = $this->factory->category->create(); 
    199199        wp_update_term( $child_category_id, 'category', array( 'parent' => $top_category_id ) ); 
    200         $export = new WP_WXR_Export(); 
     200        $export = new WP_Export_Query(); 
    201201        $this->assertNoChildBeforeParent( $export->categories() ); 
    202202    } 
     
    204204    function test_tags_should_return_all_tags() { 
    205205        $tag_id = $this->factory->tag->create(); 
    206         $export = new WP_WXR_Export(); 
     206        $export = new WP_Export_Query(); 
    207207        $this->assertEquals( array( $tag_id ), self::get_term_ids( $export->tags() ) ); 
    208208    } 
     
    210210    function test_tags_should_return_no_tags_if_we_are_requesting_only_one_post_type() { 
    211211        $category_id = $this->factory->tag->create(); 
    212         $export = new WP_WXR_Export( array( 'post_type' => 'post' ) ); 
     212        $export = new WP_Export_Query( array( 'post_type' => 'post' ) ); 
    213213        $this->assertEquals( array(), $export->tags() ); 
    214214    } 
     
    217217        register_taxonomy( 'taxonomy_all', 'post' ); 
    218218        $term_id = $this->factory->term->create( array( 'taxonomy' => 'taxonomy_all' ) ); 
    219         $export = new WP_WXR_Export(); 
     219        $export = new WP_Export_Query(); 
    220220        $this->assertEquals( array( $term_id ), self::get_term_ids( $export->custom_taxonomies_terms() ) ); 
    221221        _unregister_taxonomy( 'taxonomy_all' ); 
     
    225225        register_taxonomy( 'taxonomy_one_post_type', 'post' ); 
    226226        $term_id = $this->factory->term->create( array( 'taxonomy' => 'taxonomy_one_post_type' ) ); 
    227         $export = new WP_WXR_Export( array( 'post_type' => 'post' ) ); 
     227        $export = new WP_Export_Query( array( 'post_type' => 'post' ) ); 
    228228        $this->assertEquals( array(), $export->custom_taxonomies_terms() ); 
    229229        _unregister_taxonomy( 'taxonomy_one_post_type' ); 
     
    235235        $top_term_id = $this->factory->term->create( array( 'taxonomy' => 'heir' ) ); 
    236236        wp_update_term( $child_term_id, 'heir', array( 'parent' => $top_term_id ) ); 
    237         $export = new WP_WXR_Export(); 
     237        $export = new WP_Export_Query(); 
    238238        $this->assertNoChildBeforeParent( $export->custom_taxonomies_terms() ); 
    239239        _unregister_taxonomy( 'heir' ); 
Note: See TracChangeset for help on using the changeset viewer.