Changeset 35270
- Timestamp:
- 10/19/2015 03:28:49 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/getTermField.php
r35242 r35270 48 48 * @ticket 34245 49 49 */ 50 public function test_get_term_field_should_accept_a_WP_Term_object_ or_a_term_id() {50 public function test_get_term_field_should_accept_a_WP_Term_object_term_id_or_object() { 51 51 $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); 52 52 53 53 $this->assertInstanceOf( 'WP_Term', $term ); 54 54 $this->assertSame( $term->term_id, get_term_field( 'term_id', $term ) ); 55 $this->assertSame( $term->term_id, get_term_Field( 'term_id', $term->data ) ); 55 56 $this->assertSame( $term->term_id, get_term_field( 'term_id', $term->term_id ) ); 56 57 } … … 81 82 $this->assertSame( 'invalid_term', $_found->get_error_code() ); 82 83 } 84 85 public function test_get_term_field_term_id() { 86 $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); 87 88 $this->assertSame( $term->term_id, get_term_field( 'term_id', $term ) ); 89 $this->assertSame( $term->term_id, get_term_field( 'term_id', $term->data ) ); 90 $this->assertSame( $term->term_id, get_term_field( 'term_id', $term->term_id ) ); 91 } 92 93 public function test_get_term_field_name() { 94 $name = rand_str( 15 ); 95 96 $term = self::factory()->term->create_and_get( array( 97 'name' => $name, 98 'taxonomy' => $this->taxonomy 99 ) ); 100 101 $this->assertSame( $name, get_term_field( 'name', $term ) ); 102 $this->assertSame( $name, get_term_field( 'name', $term->data ) ); 103 $this->assertSame( $name, get_term_field( 'name', $term->term_id ) ); 104 } 105 106 public function test_get_term_field_slug_when_slug_is_set() { 107 $slug = rand_str( 15 ); 108 109 $term = self::factory()->term->create_and_get( array( 110 'taxonomy' => $this->taxonomy, 111 'slug' => $slug 112 ) ); 113 114 $this->assertSame( $slug, get_term_field( 'slug', $term ) ); 115 $this->assertSame( $slug, get_term_field( 'slug', $term->data ) ); 116 $this->assertSame( $slug, get_term_field( 'slug', $term->term_id ) ); 117 } 118 119 public function test_get_term_field_slug_when_slug_falls_back_from_name() { 120 $name = rand_str( 15 ); 121 122 $term = self::factory()->term->create_and_get( array( 123 'taxonomy' => $this->taxonomy, 124 'name' => $name 125 ) ); 126 127 $this->assertSame( $name, get_term_field( 'slug', $term ) ); 128 $this->assertSame( $name, get_term_field( 'slug', $term->data ) ); 129 $this->assertSame( $name, get_term_field( 'slug', $term->term_id ) ); 130 } 131 132 public function test_get_term_field_slug_when_slug_and_name_are_not_set() { 133 $term = self::factory()->term->create_and_get( array( 134 'taxonomy' => $this->taxonomy 135 ) ); 136 137 $this->assertSame( $term->slug, get_term_field( 'slug', $term ) ); 138 $this->assertSame( $term->slug, get_term_field( 'slug', $term->data ) ); 139 $this->assertSame( $term->slug, get_term_field( 'slug', $term->term_id ) ); 140 } 141 142 public function test_get_term_field_taxonomy() { 143 $term = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); 144 145 $this->assertSame( $this->taxonomy, get_term_field( 'taxonomy', $term ) ); 146 $this->assertSame( $this->taxonomy, get_term_field( 'taxonomy', $term->data ) ); 147 $this->assertSame( $this->taxonomy, get_term_field( 'taxonomy', $term->term_id ) ); 148 } 149 150 public function test_get_term_field_description() { 151 $desc = wpautop( rand_str() ); 152 153 $term = self::factory()->term->create_and_get( array( 154 'taxonomy' => $this->taxonomy, 155 'description' => $desc 156 ) ); 157 158 $this->assertSame( $desc, get_term_field( 'description', $term ) ); 159 $this->assertSame( $desc, get_term_field( 'description', $term->data ) ); 160 $this->assertSame( $desc, get_term_field( 'description', $term->term_id ) ); 161 } 162 163 public function test_get_term_field_parent() { 164 $parent = self::factory()->term->create_and_get( array( 'taxonomy' => $this->taxonomy ) ); 165 $term = self::factory()->term->create_and_get( array( 166 'taxonomy' => $this->taxonomy, 167 'parent' => $parent->term_id 168 ) ); 169 170 $this->assertSame( $parent->term_id, get_term_field( 'parent', $term ) ); 171 $this->assertSame( $parent->term_id, get_term_field( 'parent', $term->data ) ); 172 $this->assertSame( $parent->term_id, get_term_field( 'parent', $term->term_id ) ); 173 } 83 174 }
Note: See TracChangeset
for help on using the changeset viewer.