MDL-71051 core_user: move edit profile category form to classes

This commit is contained in:
Marina Glancy 2021-03-24 11:39:01 +01:00
parent ef3d6a3d70
commit 880aff7bf9
4 changed files with 11 additions and 9 deletions

View File

@ -22,6 +22,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_user\form;
use moodleform;
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
}
@ -34,7 +38,7 @@ require_once($CFG->dirroot.'/lib/formslib.php');
* @copyright 2007 onwards Shane Elliot {@link http://pukunui.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class category_form extends moodleform {
class profile_category_form extends moodleform {
/**
* Define the form.
@ -92,4 +96,3 @@ class category_form extends moodleform {
}
}

View File

@ -492,10 +492,9 @@ function profile_list_categories() {
* @param string $redirect
*/
function profile_edit_category($id, $redirect) {
global $DB, $OUTPUT, $CFG;
global $DB, $OUTPUT;
require_once($CFG->dirroot.'/user/profile/index_category_form.php');
$categoryform = new category_form();
$categoryform = new \core_user\form\profile_category_form();
if ($category = $DB->get_record('user_info_category', array('id' => $id))) {
$categoryform->set_data($category);

View File

@ -290,9 +290,9 @@ class profilefield_social_testcase extends provider_testcase {
private function add_profile_field($categoryid, $datatype) {
$data = $this->getDataGenerator()->create_custom_profile_field([
'datatype' => $datatype,
'shortname' => 'tstField',
'name' => 'Test field',
'description' => 'This is a test.',
'shortname' => 'icq',
'name' => 'icq',
'description' => '',
'categoryid' => $categoryid,
]);
return $data->id;

View File

@ -222,7 +222,7 @@ class core_user_profilelib_testcase extends advanced_testcase {
// Add a required, visible, unlocked custom field.
$this->getDataGenerator()->create_custom_profile_field(['shortname' => 'house', 'name' => 'House', 'required' => 1,
'visible' => 1, 'locked' => 0, 'datatype' => 'text', 'default' => null]);
'visible' => 1, 'locked' => 0, 'datatype' => 'text', 'defaultdata' => null]);
// Create some student accounts.
$hermione = $this->getDataGenerator()->create_user(['profile_field_house' => 'Gryffindor']);