Make WordPress Core

Changeset 64470


Ignore:
Timestamp:
10/17/2026 11:38:17 PM (6 days ago)
Author:
lancewillett
Message:

Tests: Add coverage for in_category().

Checks matching categories and empty category inputs against a post.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/14379

Props shailu25, mukesh27.
See #65819.

Location:
trunk/tests/phpunit/tests
Files:
1 added
1 edited

Legend:

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

    r63882 r64470  
    473473        }
    474474
    475         /**
    476          * @ticket 25706
    477          */
    478         public function test_in_category() {
    479                 $post = self::factory()->post->create_and_get();
    480 
    481                 // in_category() returns false when first parameter is empty().
    482                 $this->assertFalse( in_category( '', $post ) );
    483                 $this->assertFalse( in_category( false, $post ) );
    484                 $this->assertFalse( in_category( null, $post ) );
    485 
    486                 // Test expected behavior of in_category().
    487                 $term = wp_insert_term( 'Test', 'category' );
    488                 wp_set_object_terms( $post->ID, $term['term_id'], 'category' );
    489                 $this->assertTrue( in_category( $term['term_id'], $post ) );
    490         }
    491 
    492475        public function test_insert_category_create() {
    493476                $cat = array(
Note: See TracChangeset for help on using the changeset viewer.