WordPress.org

Make WordPress Core

Ticket #17646: 17646.tests.diff

File 17646.tests.diff, 1.1 KB (added by kovshenin, 2 years ago)
  • tests/term.php

     
    424424                unset( $GLOBALS['wp_taxonomies'][ $random_tax ] ); 
    425425        } 
    426426 
     427        /** 
     428         * @ticket 17646 
     429         */ 
     430        function test_get_object_terms_types() { 
     431                $post_id = $this->factory->post->create(); 
     432                $term = wp_insert_term( 'one', $this->taxonomy ); 
     433                wp_set_object_terms( $post_id, $term, $this->taxonomy ); 
     434 
     435                $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'all_with_object_id' ) ) ); 
     436                $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); 
     437                foreach ( $int_fields as $field ) 
     438                        $this->assertInternalType( 'int', $term->$field, $field ); 
     439 
     440                $term = array_shift( wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ) ); 
     441                $this->assertInternalType( 'int', $term, 'term' ); 
     442        } 
     443 
    427444        private function assertPostHasTerms( $post_id, $expected_term_ids, $taxonomy ) { 
    428445                $assigned_term_ids = wp_get_object_terms( $post_id, $taxonomy, array( 
    429446                        'fields' => 'ids'