Make WordPress Core


Ignore:
Timestamp:
06/18/2017 10:39:12 AM (9 years ago)
Author:
boonebgorges
Message:

Add term meta support to XML-RPC addTerm and editTerm endpoints.

This changeset also includes the new function has_term_meta(), a
counterpart to has_meta() (for posts).

Props enrico.sorcinelli.
Fixes #35991.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/term/meta.php

    r37589 r40916  
    405405        }
    406406
     407        /**
     408         * @ticket 35991
     409         */
     410        public function test_has_term_meta() {
     411                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     412
     413                $term_meta_id = add_term_meta( $t, 'foo', 'bar' );
     414                $meta = has_term_meta( $t );
     415
     416                $this->assertSame( 1, count( $meta ) );
     417
     418                $expected = array(
     419                        'meta_key' => 'foo',
     420                        'meta_value' => 'bar',
     421                        'meta_id' => $term_meta_id,
     422                        'term_id' => $t,
     423                );
     424
     425                $found = $meta[0];
     426
     427                $this->assertEquals( $expected, $found );
     428        }
     429
     430        /**
     431         * @ticket 35991
     432         */
     433        public function test_has_term_meta_empty_results() {
     434                $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) );
     435
     436                $meta = has_term_meta( $t );
     437
     438                $this->assertSame( array(), $meta );
     439        }
     440
    407441        public static function set_cache_results( $q ) {
    408442                $q->set( 'cache_results', true );
Note: See TracChangeset for help on using the changeset viewer.