Skip to content

Commit 01cb280

Browse files
Taxonomy: Add tests for handling null and zero object_ids in WP_Term_Query
1 parent 33662ad commit 01cb280

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/phpunit/tests/term/query.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,48 @@ public function test_object_ids_cache_should_be_invalidated_by_term_relationship
451451
$this->assertSameSets( array( $terms[1] ), $found );
452452
}
453453

454+
/**
455+
*
456+
* @ticket 63256
457+
*/
458+
public function test_object_ids_null_should_return_all_terms() {
459+
register_taxonomy( 'wptests_tax_1', 'post' );
460+
461+
$terms = self::factory()->term->create_many( 3, array( 'taxonomy' => 'wptests_tax_1' ) );
462+
463+
$query = new WP_Term_Query(
464+
array(
465+
'taxonomy' => 'wptests_tax_1',
466+
'object_ids' => null,
467+
'hide_empty' => false,
468+
'fields' => 'ids',
469+
)
470+
);
471+
472+
$this->assertSameSets( $terms, $query->terms );
473+
}
474+
475+
/**
476+
*
477+
* @ticket 63256
478+
*/
479+
public function test_object_ids_zero_should_be_treated_as_numeric() {
480+
register_taxonomy( 'wptests_tax_1', 'post' );
481+
482+
$term = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax_1' ) );
483+
484+
$query = new WP_Term_Query(
485+
array(
486+
'taxonomy' => 'wptests_tax_1',
487+
'object_ids' => 0,
488+
'hide_empty' => false,
489+
'fields' => 'ids',
490+
)
491+
);
492+
493+
$this->assertIsArray( $query->terms );
494+
}
495+
454496
/**
455497
* @ticket 38295
456498
* @group cache

0 commit comments

Comments
 (0)