Changeset 42343 for trunk/tests/phpunit/tests/term/splitSharedTerm.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/term/splitSharedTerm.php
r33611 r42343 26 26 27 27 register_taxonomy( 'wptests_tax', 'post' ); 28 register_taxonomy( 'wptests_tax_2', 'post', array( 29 'hierarchical' => true, 30 ) ); 28 register_taxonomy( 29 'wptests_tax_2', 'post', array( 30 'hierarchical' => true, 31 ) 32 ); 31 33 register_taxonomy( 'wptests_tax_3', 'post' ); 32 34 … … 36 38 37 39 // Manually modify because shared terms shouldn't naturally occur. 38 $wpdb->update( $wpdb->term_taxonomy, 40 $wpdb->update( 41 $wpdb->term_taxonomy, 39 42 array( 'term_id' => $t1['term_id'] ), 40 43 array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ), … … 43 46 ); 44 47 45 $wpdb->update( $wpdb->term_taxonomy, 48 $wpdb->update( 49 $wpdb->term_taxonomy, 46 50 array( 'term_id' => $t1['term_id'] ), 47 51 array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ), … … 50 54 ); 51 55 52 $t2_child = wp_insert_term( 'Foo Child', 'wptests_tax_2', array( 53 'parent' => $t1['term_id'], 54 ) ); 56 $t2_child = wp_insert_term( 57 'Foo Child', 'wptests_tax_2', array( 58 'parent' => $t1['term_id'], 59 ) 60 ); 55 61 56 62 // Split the terms and store the new term IDs. … … 59 65 60 66 $this->terms = array( 61 't1' => $t1,62 't2' => $t2,63 't3' => $t3,67 't1' => $t1, 68 't2' => $t2, 69 't3' => $t3, 64 70 't2_child' => $t2_child, 65 71 ); … … 83 89 */ 84 90 public function test_should_retain_child_terms_when_using_get_terms_parent() { 85 $children = get_terms( 'wptests_tax_2', array( 86 'parent' => $this->terms['t2']['term_id'], 87 'hide_empty' => false, 88 ) ); 91 $children = get_terms( 92 'wptests_tax_2', array( 93 'parent' => $this->terms['t2']['term_id'], 94 'hide_empty' => false, 95 ) 96 ); 89 97 90 98 $this->assertEquals( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id ); … … 95 103 */ 96 104 public function test_should_retain_child_terms_when_using_get_terms_child_of() { 97 $children = get_terms( 'wptests_tax_2', array( 98 'child_of' => $this->terms['t2']['term_id'], 99 'hide_empty' => false, 100 ) ); 105 $children = get_terms( 106 'wptests_tax_2', array( 107 'child_of' => $this->terms['t2']['term_id'], 108 'hide_empty' => false, 109 ) 110 ); 101 111 102 112 $this->assertEquals( $this->terms['t2_child']['term_taxonomy_id'], $children[0]->term_taxonomy_id ); … … 110 120 111 121 register_taxonomy( 'wptests_tax_3', 'post' ); 112 register_taxonomy( 'wptests_tax_4', 'post', array( 113 'hierarchical' => true, 114 ) ); 122 register_taxonomy( 123 'wptests_tax_4', 'post', array( 124 'hierarchical' => true, 125 ) 126 ); 115 127 116 128 $t1 = wp_insert_term( 'Foo1', 'wptests_tax_3' ); 117 129 $t2 = wp_insert_term( 'Foo1 Parent', 'wptests_tax_4' ); 118 $t3 = wp_insert_term( 'Foo1', 'wptests_tax_4', array( 119 'parent' => $t2['term_id'], 120 ) ); 121 122 // Manually modify because shared terms shouldn't naturally occur. 123 $wpdb->update( $wpdb->term_taxonomy, 130 $t3 = wp_insert_term( 131 'Foo1', 'wptests_tax_4', array( 132 'parent' => $t2['term_id'], 133 ) 134 ); 135 136 // Manually modify because shared terms shouldn't naturally occur. 137 $wpdb->update( 138 $wpdb->term_taxonomy, 124 139 array( 'term_id' => $t1['term_id'] ), 125 140 array( 'term_taxonomy_id' => $t3['term_taxonomy_id'] ), … … 148 163 149 164 // Manually modify because shared terms shouldn't naturally occur. 150 $wpdb->update( $wpdb->term_taxonomy, 165 $wpdb->update( 166 $wpdb->term_taxonomy, 151 167 array( 'term_id' => $t1['term_id'] ), 152 168 array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ), … … 175 191 176 192 // Manually modify because shared terms shouldn't naturally occur. 177 $wpdb->update( $wpdb->term_taxonomy, 193 $wpdb->update( 194 $wpdb->term_taxonomy, 178 195 array( 'term_id' => $t1['term_id'] ), 179 196 array( 'term_taxonomy_id' => $t2['term_taxonomy_id'] ), … … 182 199 ); 183 200 184 $menu_id = wp_create_nav_menu( rand_str() ); 185 $cat_menu_item = wp_update_nav_menu_item( $menu_id, 0, array( 186 'menu-item-type' => 'taxonomy', 187 'menu-item-object' => 'category', 188 'menu-item-object-id' => $t1['term_id'], 189 'menu-item-status' => 'publish' 190 ) ); 201 $menu_id = wp_create_nav_menu( rand_str() ); 202 $cat_menu_item = wp_update_nav_menu_item( 203 $menu_id, 0, array( 204 'menu-item-type' => 'taxonomy', 205 'menu-item-object' => 'category', 206 'menu-item-object-id' => $t1['term_id'], 207 'menu-item-status' => 'publish', 208 ) 209 ); 191 210 $this->assertEquals( $t1['term_id'], get_post_meta( $cat_menu_item, '_menu_item_object_id', true ) ); 192 211 … … 203 222 global $wpdb; 204 223 205 $cat_term = wp_insert_term( 'Foo Menu', 'category' );224 $cat_term = wp_insert_term( 'Foo Menu', 'category' ); 206 225 $shared_term_id = $cat_term['term_id']; 207 226 208 227 $nav_term_id = wp_create_nav_menu( 'Foo Menu' ); 209 $nav_term = get_term( $nav_term_id, 'nav_menu' ); 210 211 // Manually modify because shared terms shouldn't naturally occur. 212 $wpdb->update( $wpdb->term_taxonomy, 228 $nav_term = get_term( $nav_term_id, 'nav_menu' ); 229 230 // Manually modify because shared terms shouldn't naturally occur. 231 $wpdb->update( 232 $wpdb->term_taxonomy, 213 233 array( 'term_id' => $shared_term_id ), 214 234 array( 'term_taxonomy_id' => $nav_term->term_taxonomy_id ) … … 231 251 global $wpdb; 232 252 233 $cat_term = wp_insert_term( 'Foo Menu', 'category' );253 $cat_term = wp_insert_term( 'Foo Menu', 'category' ); 234 254 $shared_term_id = $cat_term['term_id']; 235 255 236 256 $nav_term_id = wp_create_nav_menu( 'Foo Menu' ); 237 $nav_term = get_term( $nav_term_id, 'nav_menu' ); 238 239 // Manually modify because shared terms shouldn't naturally occur. 240 $wpdb->update( $wpdb->term_taxonomy, 257 $nav_term = get_term( $nav_term_id, 'nav_menu' ); 258 259 // Manually modify because shared terms shouldn't naturally occur. 260 $wpdb->update( 261 $wpdb->term_taxonomy, 241 262 array( 'term_id' => $shared_term_id ), 242 263 array( 'term_taxonomy_id' => $nav_term->term_taxonomy_id ) 243 264 ); 244 265 245 $t1 = wp_insert_term( 'Random term', 'category' ); 246 $cat_menu_item = wp_update_nav_menu_item( $shared_term_id, 0, array( 247 'menu-item-type' => 'taxonomy', 248 'menu-item-object' => 'category', 249 'menu-item-object-id' => $t1['term_id'], 250 'menu-item-status' => 'publish' 251 ) ); 266 $t1 = wp_insert_term( 'Random term', 'category' ); 267 $cat_menu_item = wp_update_nav_menu_item( 268 $shared_term_id, 0, array( 269 'menu-item-type' => 'taxonomy', 270 'menu-item-object' => 'category', 271 'menu-item-object-id' => $t1['term_id'], 272 'menu-item-status' => 'publish', 273 ) 274 ); 252 275 253 276 // Updating the menu will split the shared term. 254 $new_nav_menu_id = wp_update_nav_menu_object( $shared_term_id, array( 255 'description' => 'Updated Foo Menu', 256 'menu-name' => 'Updated Foo Menu', 257 ) ); 277 $new_nav_menu_id = wp_update_nav_menu_object( 278 $shared_term_id, array( 279 'description' => 'Updated Foo Menu', 280 'menu-name' => 'Updated Foo Menu', 281 ) 282 ); 258 283 259 284 $menu = wp_get_nav_menu_object( $new_nav_menu_id );
Note: See TracChangeset
for help on using the changeset viewer.