Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 39... Línea 39...
39
 *
39
 *
40
 * @package    qtype_numerical
40
 * @package    qtype_numerical
41
 * @copyright  2021 The Open university
41
 * @copyright  2021 The Open university
42
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
42
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
43
 */
43
 */
44
class provider_test extends \core_privacy\tests\provider_testcase {
44
final class provider_test extends \core_privacy\tests\provider_testcase {
45
    // Include the privacy helper which has assertions on it.
45
    // Include the privacy helper which has assertions on it.
Línea 46... Línea 46...
46
 
46
 
47
    public function test_get_metadata() {
47
    public function test_get_metadata(): void {
48
        $collection = new \core_privacy\local\metadata\collection('qtype_numerical');
48
        $collection = new \core_privacy\local\metadata\collection('qtype_numerical');
49
        $actual = provider::get_metadata($collection);
49
        $actual = provider::get_metadata($collection);
50
        $this->assertEquals($collection, $actual);
50
        $this->assertEquals($collection, $actual);
Línea 51... Línea 51...
51
    }
51
    }
52
 
52
 
Línea 53... Línea 53...
53
    public function test_export_user_preferences_no_pref() {
53
    public function test_export_user_preferences_no_pref(): void {
54
        $this->resetAfterTest();
54
        $this->resetAfterTest();
55
 
55
 
Línea 65... Línea 65...
65
 
65
 
66
     * @param string $name The name of the user preference to get/set
66
     * @param string $name The name of the user preference to get/set
67
     * @param string $value The value stored in the database
67
     * @param string $value The value stored in the database
68
     * @param string $expected The expected transformed value
68
     * @param string $expected The expected transformed value
69
     */
69
     */
70
    public function test_export_user_preferences($name, $value, $expected) {
70
    public function test_export_user_preferences($name, $value, $expected): void {
71
        $this->resetAfterTest();
71
        $this->resetAfterTest();
72
        $user = $this->getDataGenerator()->create_user();
72
        $user = $this->getDataGenerator()->create_user();
73
        set_user_preference("qtype_numerical_$name", $value, $user);
73
        set_user_preference("qtype_numerical_$name", $value, $user);
74
        provider::export_user_preferences($user->id);
74
        provider::export_user_preferences($user->id);
Línea 89... Línea 89...
89
    /**
89
    /**
90
     * Create an array of valid user preferences for the multiple choice question type.
90
     * Create an array of valid user preferences for the multiple choice question type.
91
     *
91
     *
92
     * @return array Array of valid user preferences.
92
     * @return array Array of valid user preferences.
93
     */
93
     */
94
    public function user_preference_provider() {
94
    public static function user_preference_provider(): array {
95
        return [
95
        return [
96
                'default mark 1.5' => ['defaultmark', 1.5, 1.5],
96
                'default mark 1.5' => ['defaultmark', 1.5, 1.5],
97
                'penalty 20%' => ['penalty', 0.2000000, '20%'],
97
                'penalty 20%' => ['penalty', 0.2000000, '20%'],
98
                'unitrole only numerical' => ['unitrole', \qtype_numerical::UNITNONE,
98
                'unitrole only numerical' => ['unitrole', \qtype_numerical::UNITNONE,
99
                        get_string('onlynumerical', 'qtype_numerical')],
99
                        get_string('onlynumerical', 'qtype_numerical')],
Línea 111... Línea 111...
111
                'multichoice display radio buttons' => ['multichoicedisplay', \qtype_numerical::UNITRADIO,
111
                'multichoice display radio buttons' => ['multichoicedisplay', \qtype_numerical::UNITRADIO,
112
                        get_string('unitchoice', 'qtype_numerical')],
112
                        get_string('unitchoice', 'qtype_numerical')],
113
                'multichoice display select menu' => ['multichoicedisplay', \qtype_numerical::UNITSELECT,
113
                'multichoice display select menu' => ['multichoicedisplay', \qtype_numerical::UNITSELECT,
114
                        get_string('unitselect', 'qtype_numerical')],
114
                        get_string('unitselect', 'qtype_numerical')],
115
                'unitsleft left example' => ['unitsleft', '1', get_string('leftexample', 'qtype_numerical')],
115
                'unitsleft left example' => ['unitsleft', '1', get_string('leftexample', 'qtype_numerical')],
116
                'unitsleft left example' => ['unitsleft', '0', get_string('rightexample', 'qtype_numerical')]
116
                'unitsleft right example' => ['unitsleft', '0', get_string('rightexample', 'qtype_numerical')],
117
        ];
117
        ];
118
    }
118
    }
119
}
119
}