/**
  * @group term_splitting
  */
 public function test_term_splitting()
 {
     // Ensure that term splitting exists
     if (!function_exists('wp_get_split_terms')) {
         return;
     }
     global $wpdb;
     // Add our first term. This is the one that will split off.
     $t1 = wp_insert_term('Joined Term', 'category');
     // Add term meta to the term
     $value = rand_str();
     $term_id_1 = $t1['term_id'];
     fm_add_term_meta($term_id_1, 'category', 'split_test', $value);
     // Add a second term to a custom taxonomy
     register_taxonomy('fm_test_tax', 'post');
     $t2 = wp_insert_term('Second Joined Term', 'fm_test_tax');
     // Manually modify the second term to setup the term splitting
     // condition. Shared terms don't naturally occur any longer.
     $wpdb->update($wpdb->term_taxonomy, array('term_id' => $term_id_1), array('term_taxonomy_id' => $t2['term_taxonomy_id']), array('%d'), array('%d'));
     // Verify that we can retrieve the term meta
     $this->assertEquals($value, fm_get_term_meta($term_id_1, 'category', 'split_test', true));
     // Update the term to cause it to split
     $new_t1 = wp_update_term($term_id_1, 'category', array('name' => 'Split Term'));
     // Verify that the term updated and split
     $this->assertTrue(isset($new_t1['term_id']));
     $this->assertNotEquals($new_t1['term_id'], $term_id_1);
     // Verify that the term meta works at the new term id
     $this->assertEquals($value, fm_get_term_meta($new_t1['term_id'], 'category', 'split_test', true));
     // Verify that we CANNOT access the term meta at the old term id
     $this->assertEquals('', fm_get_term_meta($term_id_1, 'category', 'split_test', true));
 }
 /**
  * Callback to add term meta for the given term ID and current taxonomy.
  *
  * @see add_term_meta().
  * @see Fieldmanager_Util_Term_Meta::add_term_meta() (Deprecated).
  */
 protected function add_data($term_id, $meta_key, $meta_value, $unique = false)
 {
     if ($this->use_fm_meta) {
         return fm_add_term_meta($term_id, $this->current_taxonomy, $meta_key, $meta_value, $unique);
     } else {
         return add_term_meta($term_id, $meta_key, $meta_value, $unique);
     }
 }