Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 30... Línea 30...
30
 *
30
 *
31
 * @package   qtype_ddimageortext
31
 * @package   qtype_ddimageortext
32
 * @copyright  2019 The Open University
32
 * @copyright  2019 The Open University
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
34
 */
35
class edit_form_test extends \advanced_testcase {
35
final class edit_form_test extends \advanced_testcase {
36
    /**
36
    /**
37
     * Helper method.
37
     * Helper method.
38
     *
38
     *
39
     * @return array with two elements:
39
     * @return array with two elements:
40
     *      question_edit_form great a question form instance that can be tested.
40
     *      question_edit_form great a question form instance that can be tested.
Línea 42... Línea 42...
42
     */
42
     */
43
    protected function get_form() {
43
    protected function get_form() {
44
        $this->setAdminUser();
44
        $this->setAdminUser();
45
        $this->resetAfterTest();
45
        $this->resetAfterTest();
Línea -... Línea 46...
-
 
46
 
-
 
47
        $course = self::getDataGenerator()->create_course();
46
 
48
        $qbank = self::getDataGenerator()->create_module('qbank', ['course' => $course->id]);
47
        $syscontext = \context_system::instance();
49
        $bankcontext = \context_module::instance($qbank->cmid);
48
        $category = question_make_default_categories(array($syscontext));
50
        $category = question_get_default_category($bankcontext->id, true);
49
        $fakequestion = new \stdClass();
51
        $fakequestion = new \stdClass();
50
        $fakequestion->qtype = 'ddimageortext';
52
        $fakequestion->qtype = 'ddimageortext';
51
        $fakequestion->contextid = $syscontext->id;
53
        $fakequestion->contextid = $bankcontext->id;
52
        $fakequestion->createdby = 2;
54
        $fakequestion->createdby = 2;
53
        $fakequestion->category = $category->id;
55
        $fakequestion->category = $category->id;
54
        $fakequestion->questiontext = 'Test question';
56
        $fakequestion->questiontext = 'Test question';
55
        $fakequestion->options = new \stdClass();
57
        $fakequestion->options = new \stdClass();
Línea 58... Línea 60...
58
        $fakequestion->formoptions->movecontext = null;
60
        $fakequestion->formoptions->movecontext = null;
59
        $fakequestion->formoptions->repeatelements = true;
61
        $fakequestion->formoptions->repeatelements = true;
60
        $fakequestion->inputs = null;
62
        $fakequestion->inputs = null;
Línea 61... Línea 63...
61
 
63
 
62
        $form = new qtype_ddimageortext_edit_form(new \moodle_url('/'), $fakequestion, $category,
64
        $form = new qtype_ddimageortext_edit_form(new \moodle_url('/'), $fakequestion, $category,
Línea 63... Línea 65...
63
                new \core_question\local\bank\question_edit_contexts($syscontext));
65
                new \core_question\local\bank\question_edit_contexts($bankcontext));
64
 
66
 
Línea 65... Línea 67...
65
        return [$form, $category];
67
        return [$form, $category];