/**
  * testing user group's set up functionality
  */
 function test_user_group()
 {
     $this->RT_User_Groups->register_user_group();
     $termsid = wp_insert_term('Apple group', 'user-group', array('description' => 'A yummy apple.', 'slug' => 'apple'));
     $this->RT_User_Groups->set_user_group(1, 'apple');
     $val = RT_User_Groups::get_user_by_group_slug('apple');
     $this->assertEquals('1', $val[0]);
     $this->assertTrue($this->RT_User_Groups->is_user_has_group(1, $termsid['term_taxonomy_id']));
     $val = $this->RT_User_Groups->get_user_groups(1);
     $this->assertEquals('apple', $val[0]->slug);
     $this->RT_User_Groups->remove_user_group(1, 'apple');
     $this->assertFalse($this->RT_User_Groups->is_user_has_group(1, $termsid['term_taxonomy_id']));
 }
 /**
  * Constructor
  *
  * @param       $slug
  * @param       $label
  * @param       $caps
  * @param array $post_types add post_types on which you want support for user group
  * @param bool $allow_multiple_select
  */
 public function __construct($slug, $label, $caps, $post_types = array(), $allow_multiple_select = true)
 {
     $this->to_register_posttype = $post_types;
     self::$user_group_slug = $slug;
     $this->labels = $label;
     $this->caps = $caps;
     $this->multiple = $allow_multiple_select;
     self::auto_loader();
     $this->init();
     $this->db_upgrade();
     add_action('plugins_loaded', array($this, 'register_user_group'), 21);
     add_action('create_term', array($this, 'save_user_group'), 10, 2);
     add_action('edit_term', array($this, 'save_user_group'), 10, 2);
     add_filter(self::$user_group_slug . '_row_actions', array($this, 'row_actions'), 1, 2);
     add_action('manage_' . self::$user_group_slug . '_custom_column', array($this, 'manage_user_group_user_column_ui'), 10, 3);
     add_filter('manage_edit-' . self::$user_group_slug . '_columns', array($this, 'manage_user_group_user_column'));
     add_action('admin_print_scripts', array($this, 'js_includes'));
     add_action('admin_print_styles', array($this, 'css_includes'));
     add_action('admin_head', array($this, 'colorpicker'));
     add_action('admin_head', array($this, 'hide_slug'));
     add_action('admin_init', array($this, 'add_remove_user_group_field'), 1000);
     //User.php
     add_filter('manage_users_columns', array($this, 'add_group_columns_user'), 15, 1);
     add_action('manage_users_custom_column', array($this, 'add_group_columns_user_ui'), 15, 3);
     /* Bulk edit */
     add_action('admin_init', array($this, 'bulk_edit_action'));
     add_filter('restrict_manage_users', array($this, 'bulk_edit'));
     /* Add section to the edit user page in the admin to select profession. */
     add_action('show_user_profile', array($this, 'edit_user_user_group_section'), 99999);
     add_action('edit_user_profile', array($this, 'edit_user_user_group_section'), 99999);
     /* Update the user group when the edit user page is updated. */
     add_action('personal_options_update', array($this, 'save_user_user_group'));
     add_action('edit_user_profile_update', array($this, 'save_user_user_group'));
     add_action('pre_user_query', array($this, 'user_query'));
     /* Achieve filtering by User group. on User page. */
     add_filter('views_users', array($this, 'user_view_filters'));
     add_action('delete_user', array($this, 'delete_term_relationships'));
     add_filter('sanitize_user', array($this, 'disable_username'));
     add_action('wp_ajax_remove_group', array($this, 'remove_group'));
 }