Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 29... Línea 29...
29
 * @author     Andrew Madden <andrewmadden@catalyst-au.net>
29
 * @author     Andrew Madden <andrewmadden@catalyst-au.net>
30
 * @copyright  2021 Catalyst IT
30
 * @copyright  2021 Catalyst IT
31
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 * @covers \quizaccess_seb\external\validate_quiz_access
32
 * @covers \quizaccess_seb\external\validate_quiz_access
33
 */
33
 */
34
class validate_quiz_access_test extends \advanced_testcase {
34
final class validate_quiz_access_test extends \advanced_testcase {
35
    use \quizaccess_seb_test_helper_trait;
35
    use \quizaccess_seb_test_helper_trait;
Línea 36... Línea 36...
36
 
36
 
37
    /**
37
    /**
38
     * This method runs before every test.
38
     * This method runs before every test.
Línea 52... Línea 52...
52
    /**
52
    /**
53
     * Bad parameter provider.
53
     * Bad parameter provider.
54
     *
54
     *
55
     * @return array
55
     * @return array
56
     */
56
     */
57
    public function bad_parameters_provider(): array {
57
    public static function bad_parameters_provider(): array {
58
        return [
58
        return [
59
            'no params' => [
59
            'no params' => [
60
                'cmid' => null,
60
                'cmid' => null,
61
                'url' => null,
61
                'url' => null,
62
                'configkey' => null,
62
                'configkey' => null,
63
                '/Invalid parameter value detected \(Missing required key in single structure: cmid\)/'
63
                'messageregex' => '/Invalid parameter value detected \(Missing required key in single structure: cmid\)/'
64
            ],
64
            ],
65
            'no course module id' => [
65
            'no course module id' => [
66
                'cmid' => null,
66
                'cmid' => null,
67
                'url' => 'https://www.example.com/moodle',
67
                'url' => 'https://www.example.com/moodle',
68
                'configkey' => hash('sha256', 'configkey'),
68
                'configkey' => hash('sha256', 'configkey'),
69
                '/Invalid parameter value detected \(Missing required key in single structure: cmid\)/'
69
                'messageregex' => '/Invalid parameter value detected \(Missing required key in single structure: cmid\)/'
70
            ],
70
            ],
71
            'no url' => [
71
            'no url' => [
72
                'cmid' => 123,
72
                'cmid' => 123,
73
                'url' => null,
73
                'url' => null,
74
                'configkey' => hash('sha256', 'configkey'),
74
                'configkey' => hash('sha256', 'configkey'),
75
                '/Invalid parameter value detected \(Missing required key in single structure: url\)/'
75
                'messageregex' => '/Invalid parameter value detected \(Missing required key in single structure: url\)/'
76
            ],
76
            ],
77
            'cmid is not an int' => [
77
            'cmid is not an int' => [
78
                'cmid' => 'test',
78
                'cmid' => 'test',
79
                'url' => 'https://www.example.com/moodle',
79
                'url' => 'https://www.example.com/moodle',
80
                'configkey' => null,
80
                'configkey' => null,
81
                '/Invalid external api parameter: the value is "test", the server was expecting "int" type/'
81
                'messageregex' => '/Invalid external api parameter: the value is "test", the server was expecting "int" type/'
82
            ],
82
            ],
83
            'url is not a url' => [
83
            'url is not a url' => [
84
                'cmid' => 123,
84
                'cmid' => 123,
85
                'url' => 123,
85
                'url' => 123,
86
                'configkey' => hash('sha256', 'configkey'),
86
                'configkey' => hash('sha256', 'configkey'),
87
                '/Invalid external api parameter: the value is "123", the server was expecting "url" type/'
87
                'messageregex' => '/Invalid external api parameter: the value is "123", the server was expecting "url" type/'
88
            ],
88
            ],
89
        ];
89
        ];
90
    }
90
    }
Línea 91... Línea 91...
91
 
91