| @@ 883-906 (lines=24) @@ | ||
| 880 | $this->assertEqualSets(array( $t2, $t4 ), $found); |
|
| 881 | } |
|
| 882 | ||
| 883 | public function test_get_terms_hierarchical_tax_hide_empty_false_fields_ids() |
|
| 884 | { |
|
| 885 | // Set up a clean taxonomy. |
|
| 886 | $tax = 'hierarchical_fields'; |
|
| 887 | register_taxonomy($tax, 'post', array( 'hierarchical' => true )); |
|
| 888 | ||
| 889 | $terms = $this->create_hierarchical_terms_and_posts(); |
|
| 890 | ||
| 891 | $found = get_terms( |
|
| 892 | $tax, array( |
|
| 893 | 'hide_empty' => false, |
|
| 894 | 'fields' => 'ids', |
|
| 895 | ) |
|
| 896 | ); |
|
| 897 | ||
| 898 | $expected = array( |
|
| 899 | $terms['parent1'], |
|
| 900 | $terms['parent2'], |
|
| 901 | $terms['child1'], |
|
| 902 | $terms['child2'], |
|
| 903 | $terms['grandchild1'], |
|
| 904 | ); |
|
| 905 | ||
| 906 | _unregister_taxonomy('hierarchical_fields'); |
|
| 907 | ||
| 908 | $this->assertEqualSets($expected, $found); |
|
| 909 | } |
|
| @@ 1133-1154 (lines=22) @@ | ||
| 1130 | $this->assertEqualSetsWithIndex($expected, $found); |
|
| 1131 | } |
|
| 1132 | ||
| 1133 | public function test_get_terms_hierarchical_tax_hide_empty_true_fields_idparent() |
|
| 1134 | { |
|
| 1135 | // Set up a clean taxonomy. |
|
| 1136 | $tax = 'hierarchical_fields'; |
|
| 1137 | register_taxonomy($tax, 'post', array( 'hierarchical' => true )); |
|
| 1138 | ||
| 1139 | $terms = $this->create_hierarchical_terms_and_posts(); |
|
| 1140 | ||
| 1141 | $found = get_terms( |
|
| 1142 | $tax, array( |
|
| 1143 | 'hide_empty' => true, |
|
| 1144 | 'fields' => 'id=>parent', |
|
| 1145 | ) |
|
| 1146 | ); |
|
| 1147 | ||
| 1148 | $expected = array( |
|
| 1149 | $terms['parent1'] => 0, |
|
| 1150 | $terms['parent2'] => 0, |
|
| 1151 | $terms['child1'] => $terms['parent1'], |
|
| 1152 | ); |
|
| 1153 | ||
| 1154 | _unregister_taxonomy('hierarchical_fields'); |
|
| 1155 | ||
| 1156 | $this->assertEqualSetsWithIndex($expected, $found); |
|
| 1157 | } |
|