Skip to content

Commit 792bed6

Browse files
committed
Add test case which reproduces the error without the fix
1 parent 5168c1f commit 792bed6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/phpunit/tests/term/wpDeleteObjectTermRelationships.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,21 @@ public function test_array_of_taxonomies() {
5353

5454
$this->assertSameSets( array( $t2 ), $terms );
5555
}
56+
57+
public function test_delete_when_error() {
58+
$taxonomy_name = 'wptests_tax';
59+
register_taxonomy( $taxonomy_name, 'post' );
60+
$term_id = self::factory()->term->create( array( 'taxonomy' => $taxonomy_name ) );
61+
$object_id = 567;
62+
wp_set_object_terms( $object_id, array( $term_id ), $taxonomy_name );
63+
64+
// Confirm the setup.
65+
$terms = wp_get_object_terms( $object_id, array( $taxonomy_name ), array( 'fields' => 'ids' ) );
66+
$this->assertSame( array( $term_id ), $terms, 'Expected same object terms.' );
67+
68+
// Try wp_delete_object_term_relationships() when the taxonomy is invalid (no change expected).
69+
wp_delete_object_term_relationships( $object_id, 'wptests_taxation' );
70+
$terms = wp_get_object_terms( $object_id, array( $taxonomy_name ), array( 'fields' => 'ids' ) );
71+
$this->assertSame( array( $term_id ), $terms, 'Expected the object terms to be unchanged.' );
72+
}
5673
}

0 commit comments

Comments
 (0)