Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 36... Línea 36...
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 *
37
 *
38
 * @covers \question_type
38
 * @covers \question_type
39
 * @covers \qtype_shortanswer
39
 * @covers \qtype_shortanswer
40
 */
40
 */
41
class question_type_test extends \advanced_testcase {
41
final class question_type_test extends \advanced_testcase {
42
    protected $qtype;
42
    protected $qtype;
Línea 43... Línea 43...
43
 
43
 
-
 
44
    protected function setUp(): void {
44
    protected function setUp(): void {
45
        parent::setUp();
45
        $this->qtype = new qtype_shortanswer();
46
        $this->qtype = new qtype_shortanswer();
Línea 46... Línea 47...
46
    }
47
    }
47
 
48
 
-
 
49
    protected function tearDown(): void {
48
    protected function tearDown(): void {
50
        $this->qtype = null;
Línea 49... Línea 51...
49
        $this->qtype = null;
51
        parent::tearDown();
50
    }
52
    }
51
 
53
 
Línea 116... Línea 118...
116
        $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
118
        $returnedfromsave = $this->qtype->save_question($questiondata, $fromform);
117
        $actualquestionsdata = question_load_questions([$returnedfromsave->id], 'qbe.idnumber');
119
        $actualquestionsdata = question_load_questions([$returnedfromsave->id], 'qbe.idnumber');
118
        $actualquestiondata = end($actualquestionsdata);
120
        $actualquestiondata = end($actualquestionsdata);
Línea 119... Línea 121...
119
 
121
 
120
        foreach ($questiondata as $property => $value) {
122
        foreach ($questiondata as $property => $value) {
121
            if (!in_array($property, array('id', 'timemodified', 'timecreated', 'options'))) {
123
            if (!in_array($property, ['id', 'timemodified', 'timecreated', 'options', 'hints'])) {
122
                $this->assertEquals($value, $actualquestiondata->$property);
124
                $this->assertEquals($value, $actualquestiondata->$property);
123
            }
125
            }
Línea 124... Línea 126...
124
        }
126
        }
Línea 136... Línea 138...
136
                if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
138
                if (!in_array($ansproperty, array('id', 'question', 'answerformat'))) {
137
                    $this->assertEquals($ansvalue, $actualanswer->$ansproperty);
139
                    $this->assertEquals($ansvalue, $actualanswer->$ansproperty);
138
                }
140
                }
139
            }
141
            }
140
        }
142
        }
-
 
143
 
-
 
144
        $this->assertCount(1, $actualquestiondata->hints);
-
 
145
        $hint = array_pop($actualquestiondata->hints);
-
 
146
        $this->assertEquals($formdata->hint[0]['text'], $hint->hint);
-
 
147
        $this->assertEquals($formdata->hint[0]['format'], $hint->hintformat);
141
    }
148
    }
Línea 142... Línea 149...
142
 
149
 
143
    public function test_question_saving_trims_answers(): void {
150
    public function test_question_saving_trims_answers(): void {
144
        $this->resetAfterTest(true);
151
        $this->resetAfterTest(true);