function test_insert_at_position()
 {
     $test_source = array();
     for ($i = 0; $i < 100; ++$i) {
         $test_source["item_{$i}"] = $i;
     }
     $test_to_insert = array('insert_first' => 1042, 'insert_last' => 1043);
     // Inserting at specified index
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, 0);
     $this->insert_at_position_check($result, 0, 1, array('item_0' => 2, 'item_99' => 101));
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, 5);
     $this->insert_at_position_check($result, 5, 6, array('item_0' => 0, 'item_4' => 4, 'item_5' => 7, 'item_99' => 101));
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, count($test_source));
     $this->insert_at_position_check($result, 100, 101, array('item_0' => 0, 'item_99' => 99));
     // Negative numeric index
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, -1);
     $this->insert_at_position_check($result, 100, 101, array('item_0' => 0, 'item_99' => 99));
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, -1000);
     $this->insert_at_position_check($result, 0, 1, array('item_0' => 2, 'item_99' => 101));
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, -3);
     $this->insert_at_position_check($result, 98, 99, array('item_0' => 0, 'item_97' => 97, 'item_98' => 100, 'item_99' => 101));
     // Inserting by element key
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, array('key' => 'item_4', 'where' => 'after'));
     $this->insert_at_position_check($result, 5, 6, array('item_0' => 0, 'item_4' => 4, 'item_5' => 7, 'item_99' => 101));
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, array('key' => 'item_5', 'where' => 'before'));
     $this->insert_at_position_check($result, 5, 6, array('item_0' => 0, 'item_4' => 4, 'item_5' => 7, 'item_99' => 101));
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, array('where' => 'before'));
     $this->insert_at_position_check($result, 0, 1, array('item_0' => 2, 'item_99' => 101));
     $result = WPCF_Utils::insert_at_position($test_source, $test_to_insert, array('where' => 'after'));
     $this->insert_at_position_check($result, 100, 101, array('item_0' => 0, 'item_99' => 99));
     $this->expectOutputString('');
 }
 /**
  * Add a column for each term field on the term listing page.
  *
  * @param string[string] $columns Column definitions (column name => display name).
  * @return string[string] Updated column definitions.
  * @link https://make.wordpress.org/docs/plugin-developer-handbook/10-plugin-components/custom-list-table-columns/
  * @since 1.9.1
  */
 public function manage_term_listing_columns($columns)
 {
     $taxonomy_slug = wpcf_getget('taxonomy');
     $groups = WPCF_Field_Group_Term_Factory::get_instance()->get_groups_by_taxonomy($taxonomy_slug);
     $columns_to_insert = array();
     foreach ($groups as $group) {
         foreach ($group->get_field_definitions() as $field_definition) {
             $columns_to_insert[self::LISTING_COLUMN_PREFIX . $field_definition->get_slug()] = $field_definition->get_display_name();
         }
     }
     // Insert before the last column, which displays counts of posts using the term (that's probably why column
     // has the label "Count" and name "posts" :-P).
     $columns = WPCF_Utils::insert_at_position($columns, $columns_to_insert, array('key' => 'posts', 'where' => 'before'));
     return $columns;
 }