mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
This improves performance, readability, and consistency throughout core. * `intval()` → `(int)` * `strval()` → `(string)` * `floatval()` → `(float)` Props ayeshrajans. Fixes #42918. git-svn-id: https://develop.svn.wordpress.org/trunk@49108 602fd350-edb4-49c9-b593-d223f7449a82
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group taxonomy
|
|
*/
|
|
class Tests_Term_WpDeleteTerm extends WP_UnitTestCase {
|
|
protected $deleted_term;
|
|
protected $object_ids;
|
|
|
|
/**
|
|
* @ticket 33485
|
|
* @ticket 35213
|
|
*/
|
|
public function test_count_property_passed_to_filters_should_reflect_pre_deleted_term() {
|
|
register_taxonomy( 'wptests_tax', 'post' );
|
|
|
|
$terms = self::factory()->term->create_many(
|
|
2,
|
|
array(
|
|
'taxonomy' => 'wptests_tax',
|
|
)
|
|
);
|
|
|
|
$post_id = self::factory()->post->create();
|
|
|
|
wp_set_object_terms( $post_id, array( $terms[0] ), 'wptests_tax' );
|
|
|
|
add_action( 'delete_term', array( $this, 'catch_deleted_term' ), 10, 5 );
|
|
|
|
wp_delete_term( $terms[0], 'wptests_tax' );
|
|
$this->assertSame( 1, $this->deleted_term->count );
|
|
$this->assertSame( $this->object_ids, array( (string) $post_id ) );
|
|
|
|
wp_delete_term( $terms[1], 'wptests_tax' );
|
|
$this->assertSame( 0, $this->deleted_term->count );
|
|
$this->assertSame( $this->object_ids, array() );
|
|
}
|
|
|
|
public function catch_deleted_term( $term_id, $tt_id, $taxonomy, $deleted_term, $object_ids ) {
|
|
$this->deleted_term = $deleted_term;
|
|
$this->object_ids = $object_ids;
|
|
}
|
|
}
|