/**
  * Tests deepsight_datatable_usersetuser_base::get_userset_subsets
  * @dataProvider dataprovider_get_userset_subsets
  * @param int $parentuserset The ID of a userset to pass to the function as the parent userset ID.
  * @param bool $includeparent Whether to include the parent ID in the return array.
  * @param array $expectedresults The expected return value.
  */
 public function test_get_userset_subsets($parentuserset, $includeparent, $expectedresults)
 {
     $dataset = $this->createCsvDataSet(array(user::TABLE => elispm::file('tests/fixtures/deepsight_user.csv'), userset::TABLE => elispm::file('tests/fixtures/deepsight_usersetwithsubsets.csv')));
     $this->loadDataSet($dataset);
     accesslib_clear_all_caches(true);
     // Set up contexts.
     for ($i = 1; $i <= 6; $i++) {
         $ctx = \local_elisprogram\context\userset::instance($i);
     }
     accesslib_clear_all_caches(true);
     $actualresults = deepsight_datatable_standard::get_userset_subsets($parentuserset, $includeparent);
     $this->assertEquals($expectedresults, array_keys($actualresults));
 }
Exemple #2
0
 /**
  * Adds the custom field tables, if necessary, to the JOIN sql.
  *
  * @param array $filters An array of active filters to use to determne join sql.
  * @return array An array of JOIN sql fragments.
  */
 protected function get_join_sql(array $filters = array())
 {
     $joinsql = parent::get_join_sql($filters);
     $joinsql[] = 'JOIN {' . curriculum::TABLE . '} pgm ON pgm.id = element.curid';
     $activecustomfields = array_intersect_key($this->custom_fields, $filters);
     if (!empty($activecustomfields)) {
         $joinsql[] = 'JOIN {context} ctx ON ctx.instanceid = element.id AND ctx.contextlevel=' . CONTEXT_ELIS_TRACK;
         foreach ($activecustomfields as $fieldname => $field) {
             $customfieldjoin = 'LEFT JOIN {local_eliscore_fld_data_' . $field->datatype . '} ' . $fieldname . ' ON ';
             $customfieldjoin .= $fieldname . '.contextid = ctx.id AND ' . $fieldname . '.fieldid=' . $field->id;
             $joinsql[] = $customfieldjoin;
         }
     }
     return $joinsql;
 }