| | 155 | * @ticket 25710 |
| | 156 | */ |
| | 157 | function test_get_terms_exclude_tree() { |
| | 158 | |
| | 159 | $term_id_uncategorized = get_option( 'default_category' ); |
| | 160 | |
| | 161 | $term_id1 = $this->factory->category->create(); |
| | 162 | $term_id11 = $this->factory->category->create( array( 'parent' => $term_id1 ) ); |
| | 163 | $term_id2 = $this->factory->category->create(); |
| | 164 | $term_id22 = $this->factory->category->create( array( 'parent' => $term_id2 ) ); |
| | 165 | |
| | 166 | // There's something else broken in the cache cleaning routines that leads to this having to be done manually |
| | 167 | delete_option( 'category_children' ); |
| | 168 | |
| | 169 | $terms = get_terms( 'category', array( |
| | 170 | 'exclude' => $term_id_uncategorized, |
| | 171 | 'fields' => 'ids', |
| | 172 | 'hide_empty' => false, |
| | 173 | ) ); |
| | 174 | $this->assertEquals( array( $term_id1, $term_id11, $term_id2, $term_id22 ), $terms ); |
| | 175 | |
| | 176 | $terms = get_terms( 'category', array( |
| | 177 | 'fields' => 'ids', |
| | 178 | 'exclude_tree' => "$term_id1,$term_id_uncategorized", |
| | 179 | 'hide_empty' => false, |
| | 180 | ) ); |
| | 181 | |
| | 182 | $this->assertEquals( array( $term_id2, $term_id22 ), $terms ); |
| | 183 | |
| | 184 | } |
| | 185 | |
| | 186 | /** |