WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (6 years ago)
Author:
wonderboymusic
Message:

Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.

File:
1 edited

Legend:

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

    r35225 r35242  
    2222    function test_get_all_category_ids() {
    2323        // create categories
    24         self::$factory->category->create_many( 2 );
     24        self::factory()->category->create_many( 2 );
    2525
    2626        // create new taxonomy to ensure not included
     
    3939
    4040        // create Test Categories
    41         $testcat = self::$factory->category->create_and_get(
     41        $testcat = self::factory()->category->create_and_get(
    4242            array(
    4343                'slug' => 'testcat',
     
    4545            )
    4646        );
    47         $testcat2 = self::$factory->category->create_and_get(
     47        $testcat2 = self::factory()->category->create_and_get(
    4848            array(
    4949                'slug' => 'testcat2',
     
    7474            'description' => 'Category Test'
    7575        );
    76         $testcat = self::$factory->category->create_and_get( $testcat_array );
     76        $testcat = self::factory()->category->create_and_get( $testcat_array );
    7777        $testcat_array['term_id'] = $testcat->term_id;
    7878
     
    8383            'parent' => $testcat->term_id
    8484        );
    85         $testcat2 = self::$factory->category->create_and_get( $testcat2_array );
     85        $testcat2 = self::factory()->category->create_and_get( $testcat2_array );
    8686        $testcat2_array['term_id'] = $testcat2->term_id;
    8787
     
    146146
    147147        // create Test Category
    148         $testcat = self::$factory->category->create_and_get(
     148        $testcat = self::factory()->category->create_and_get(
    149149            array(
    150150                'slug' => 'testcat',
     
    166166
    167167        // create Test Category
    168         $testcat = self::$factory->category->create_and_get(
     168        $testcat = self::factory()->category->create_and_get(
    169169            array(
    170170                'slug' => 'testcat',
     
    186186
    187187        // create Test Categories
    188         $root_id = self::$factory->category->create(
     188        $root_id = self::factory()->category->create(
    189189            array(
    190190                'slug' => 'root',
    191191            )
    192192        );
    193         $root_cat_id = self::$factory->category->create(
     193        $root_cat_id = self::factory()->category->create(
    194194            array(
    195195                'slug' => 'cat',
     
    197197            )
    198198        );
    199         $root_cat_cat_id = self::$factory->category->create(
     199        $root_cat_cat_id = self::factory()->category->create(
    200200            array(
    201201                'slug' => 'cat', //note this is modified on create
     
    203203            )
    204204        );
    205         $root_path_id = self::$factory->category->create(
     205        $root_path_id = self::factory()->category->create(
    206206            array(
    207207                'slug' => 'path',
     
    209209            )
    210210        );
    211         $root_path_cat_id = self::$factory->category->create(
     211        $root_path_cat_id = self::factory()->category->create(
    212212            array(
    213213                'slug' => 'cat', //note this is modified on create
     
    215215            )
    216216        );
    217         $root_level_id = self::$factory->category->create(
     217        $root_level_id = self::factory()->category->create(
    218218            array(
    219219                'slug' => 'level-1',
     
    221221            )
    222222        );
    223         $root_level_cat_id = self::$factory->category->create(
     223        $root_level_cat_id = self::factory()->category->create(
    224224            array(
    225225                'slug' => 'cat', //note this is modified on create
     
    249249    public function test_wp_dropdown_categories_value_field_should_default_to_term_id() {
    250250        // Create a test category.
    251         $cat_id = self::$factory->category->create( array(
     251        $cat_id = self::factory()->category->create( array(
    252252            'name' => 'Test Category',
    253253            'slug' => 'test_category',
     
    269269    public function test_wp_dropdown_categories_value_field_term_id() {
    270270        // Create a test category.
    271         $cat_id = self::$factory->category->create( array(
     271        $cat_id = self::factory()->category->create( array(
    272272            'name' => 'Test Category',
    273273            'slug' => 'test_category',
     
    290290    public function test_wp_dropdown_categories_value_field_slug() {
    291291        // Create a test category.
    292         $cat_id = self::$factory->category->create( array(
     292        $cat_id = self::factory()->category->create( array(
    293293            'name' => 'Test Category',
    294294            'slug' => 'test_category',
     
    311311    public function test_wp_dropdown_categories_value_field_should_fall_back_on_term_id_when_an_invalid_value_is_provided() {
    312312        // Create a test category.
    313         $cat_id = self::$factory->category->create( array(
     313        $cat_id = self::factory()->category->create( array(
    314314            'name' => 'Test Category',
    315315            'slug' => 'test_category',
     
    331331     */
    332332    public function test_wp_dropdown_categories_selected_should_respect_custom_value_field() {
    333         $c1 = self::$factory->category->create( array(
     333        $c1 = self::factory()->category->create( array(
    334334            'name' => 'Test Category 1',
    335335            'slug' => 'test_category_1',
    336336        ) );
    337337
    338         $c2 = self::$factory->category->create( array(
     338        $c2 = self::factory()->category->create( array(
    339339            'name' => 'Test Category 2',
    340340            'slug' => 'test_category_2',
     
    355355     */
    356356    public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_no_selected_value_is_explicitly_passed_and_value_field_does_not_have_string_values() {
    357         $cats = self::$factory->category->create_many( 3 );
     357        $cats = self::factory()->category->create_many( 3 );
    358358
    359359        $found = wp_dropdown_categories( array(
     
    376376     */
    377377    public function test_wp_dropdown_categories_show_option_all_should_be_selected_if_selected_value_of_0_string_is_explicitly_passed_and_value_field_does_not_have_string_values() {
    378         $cats = self::$factory->category->create_many( 3 );
     378        $cats = self::factory()->category->create_many( 3 );
    379379
    380380        $found = wp_dropdown_categories( array(
Note: See TracChangeset for help on using the changeset viewer.