| | 88 | /** |
| | 89 | * Test inserting a new term with a parent |
| | 90 | */ |
| | 91 | function test_insert_term_with_parent_by_id() { |
| | 92 | |
| | 93 | $term_parent = wp_insert_term( 'My test parent Term', 'category' ); |
| | 94 | |
| | 95 | $term_child = wp_insert_term( 'My child term', 'category', array( 'parent' => $term_parent['term_id'] ) ); |
| | 96 | |
| | 97 | $term_chid_object = get_term( (int) $term_child['term_id'], 'category' ); |
| | 98 | |
| | 99 | wp_delete_term( $term_parent['term_id'], 'category' ); |
| | 100 | wp_delete_term( $term_child['term_id'], 'category' ); |
| | 101 | |
| | 102 | $this->assertEquals( $term_parent['term_id'], $term_chid_object->parent ); |
| | 103 | } |
| | 104 | |
| | 105 | /** |
| | 106 | * @ticket 23378 |
| | 107 | */ |
| | 108 | function test_insert_term_with_parent_by_slug() { |
| | 109 | |
| | 110 | $term_parent = wp_insert_term( 'My test parent Term', 'category' ); |
| | 111 | $term_parent_object = get_term( (int) $term_parent['term_id'], 'category' ); |
| | 112 | |
| | 113 | $term_child = wp_insert_term( 'My child term', 'category', array( 'parent' => $term_parent_object->slug ) ); |
| | 114 | |
| | 115 | $term_chid_object = get_term( (int) $term_child['term_id'], 'category' ); |
| | 116 | |
| | 117 | wp_delete_term( $term_parent['term_id'], 'category' ); |
| | 118 | wp_delete_term( $term_child['term_id'], 'category' ); |
| | 119 | |
| | 120 | $this->assertEquals( $term_parent['term_id'], $term_chid_object->parent ); |
| | 121 | |
| | 122 | } |
| | 123 | |
| | 124 | /** |
| | 125 | * @ticket 23378 |
| | 126 | */ |
| | 127 | function test_update_term_with_parent_by_slug() { |
| | 128 | |
| | 129 | $term_parent = wp_insert_term( 'My test parent Term', 'category' ); |
| | 130 | $term_parent_object = get_term( (int) $term_parent['term_id'], 'category' ); |
| | 131 | |
| | 132 | $term_child = wp_insert_term( 'My child term', 'category' ); |
| | 133 | |
| | 134 | wp_update_term( (int) $term_child['term_id'], 'category', array( 'parent' => $term_parent_object->slug ) ); |
| | 135 | |
| | 136 | $term_chid_object = get_term( (int) $term_child['term_id'], 'category' ); |
| | 137 | |
| | 138 | wp_delete_term( $term_parent['term_id'], 'category' ); |
| | 139 | wp_delete_term( $term_child['term_id'], 'category' ); |
| | 140 | |
| | 141 | $this->assertEquals( $term_parent['term_id'], $term_chid_object->parent ); |
| | 142 | |
| | 143 | } |
| | 144 | |