Make WordPress Core


Ignore:
Timestamp:
12/23/2015 11:43:03 PM (8 years ago)
Author:
obenland
Message:

Taxonomy: Pass object ids to delete_* actions.

Allows for more targeted updates to affected posts in callbacks.
Disambiguates $objects variable and amends unit tests.

Fixes #35213.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/wpDeleteTerm.php

    r35242 r36080  
    66class Tests_Term_WpDeleteTerm extends WP_UnitTestCase {
    77    protected $deleted_term;
     8    protected $object_ids;
    89
    910    /**
    1011     * @ticket 33485
     12     * @ticket 35213
    1113     */
    1214    public function test_count_property_passed_to_filters_should_reflect_pre_deleted_term() {
     
    1719        ) );
    1820
    19         $p = self::factory()->post->create();
     21        $post_id = self::factory()->post->create();
    2022
    21         wp_set_object_terms( $p, array( $terms[0] ), 'wptests_tax' );
     23        wp_set_object_terms( $post_id, array( $terms[0] ), 'wptests_tax' );
    2224
    23         add_action( 'delete_term', array( $this, 'catch_deleted_term' ), 10, 4 );
     25        add_action( 'delete_term', array( $this, 'catch_deleted_term' ), 10, 5 );
    2426
    2527        wp_delete_term( $terms[0], 'wptests_tax' );
    2628        $this->assertEquals( 1, $this->deleted_term->count );
     29        $this->assertSame( $this->object_ids, array( "$post_id" ) );
    2730
    2831        wp_delete_term( $terms[1], 'wptests_tax' );
    2932        $this->assertEquals( 0, $this->deleted_term->count );
     33        $this->assertSame( $this->object_ids, array() );
    3034    }
    3135
    32     public function catch_deleted_term( $term_id, $tt_id, $taxonomy, $deleted_term ) {
     36    public function catch_deleted_term( $term_id, $tt_id, $taxonomy, $deleted_term, $object_ids ) {
    3337        $this->deleted_term = $deleted_term;
     38        $this->object_ids = $object_ids;
    3439    }
    3540}
Note: See TracChangeset for help on using the changeset viewer.