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
 * @package    tool_dataprivacy
29
 * @package    tool_dataprivacy
30
 * @covers     \tool_dataprivacy\api
30
 * @covers     \tool_dataprivacy\api
31
 * @copyright  2018 Jun Pataleta
31
 * @copyright  2018 Jun Pataleta
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
33
 */
34
class api_test extends \advanced_testcase {
34
final class api_test extends \advanced_testcase {
Línea 35... Línea 35...
35
 
35
 
36
    /**
36
    /**
37
     * Ensure that the check_can_manage_data_registry function fails cap testing when a user without capabilities is
37
     * Ensure that the check_can_manage_data_registry function fails cap testing when a user without capabilities is
38
     * tested with the default context.
38
     * tested with the default context.
Línea 631... Línea 631...
631
    /**
631
    /**
632
     * Data provider for data request creation tests.
632
     * Data provider for data request creation tests.
633
     *
633
     *
634
     * @return array
634
     * @return array
635
     */
635
     */
636
    public function data_request_creation_provider() {
636
    public static function data_request_creation_provider(): array {
637
        return [
637
        return [
638
            'Export request by user, automatic approval off' => [
638
            'Export request by user, automatic approval off' => [
639
                false, api::DATAREQUEST_TYPE_EXPORT, 'automaticdataexportapproval', false, 0,
639
                false, api::DATAREQUEST_TYPE_EXPORT, 'automaticdataexportapproval', false, 0,
640
                api::DATAREQUEST_STATUS_AWAITING_APPROVAL, 0, 0
640
                api::DATAREQUEST_STATUS_AWAITING_APPROVAL, 0, 0
641
            ],
641
            ],
Línea 813... Línea 813...
813
    /**
813
    /**
814
     * Data provider for \tool_dataprivacy_api_testcase::test_get_data_requests().
814
     * Data provider for \tool_dataprivacy_api_testcase::test_get_data_requests().
815
     *
815
     *
816
     * @return array
816
     * @return array
817
     */
817
     */
818
    public function get_data_requests_provider() {
818
    public static function get_data_requests_provider(): array {
819
        $completeonly = [api::DATAREQUEST_STATUS_COMPLETE, api::DATAREQUEST_STATUS_DOWNLOAD_READY, api::DATAREQUEST_STATUS_DELETED];
819
        $completeonly = [api::DATAREQUEST_STATUS_COMPLETE, api::DATAREQUEST_STATUS_DOWNLOAD_READY, api::DATAREQUEST_STATUS_DELETED];
820
        $completeandcancelled = array_merge($completeonly, [api::DATAREQUEST_STATUS_CANCELLED]);
820
        $completeandcancelled = array_merge($completeonly, [api::DATAREQUEST_STATUS_CANCELLED]);
Línea 821... Línea 821...
821
 
821
 
822
        return [
822
        return [
Línea 998... Línea 998...
998
    }
998
    }
Línea 999... Línea 999...
999
 
999
 
1000
    /**
1000
    /**
1001
     * Data provider for test_has_ongoing_request.
1001
     * Data provider for test_has_ongoing_request.
1002
     */
1002
     */
1003
    public function status_provider() {
1003
    public static function status_provider(): array {
1004
        return [
1004
        return [
1005
            [api::DATAREQUEST_STATUS_AWAITING_APPROVAL, true],
1005
            [api::DATAREQUEST_STATUS_AWAITING_APPROVAL, true],
1006
            [api::DATAREQUEST_STATUS_APPROVED, true],
1006
            [api::DATAREQUEST_STATUS_APPROVED, true],
1007
            [api::DATAREQUEST_STATUS_PROCESSING, true],
1007
            [api::DATAREQUEST_STATUS_PROCESSING, true],
Línea 1088... Línea 1088...
1088
    /**
1088
    /**
1089
     * Data provider function for test_notify_dpo
1089
     * Data provider function for test_notify_dpo
1090
     *
1090
     *
1091
     * @return array
1091
     * @return array
1092
     */
1092
     */
1093
    public function notify_dpo_provider() {
1093
    public static function notify_dpo_provider(): array {
1094
        return [
1094
        return [
1095
            [false, api::DATAREQUEST_TYPE_EXPORT, 'requesttypeexport', 'Export my user data'],
1095
            [false, api::DATAREQUEST_TYPE_EXPORT, 'requesttypeexport', 'Export my user data'],
1096
            [false, api::DATAREQUEST_TYPE_DELETE, 'requesttypedelete', 'Delete my user data'],
1096
            [false, api::DATAREQUEST_TYPE_DELETE, 'requesttypedelete', 'Delete my user data'],
1097
            [false, api::DATAREQUEST_TYPE_OTHERS, 'requesttypeothers', 'Nothing. Just wanna say hi'],
1097
            [false, api::DATAREQUEST_TYPE_OTHERS, 'requesttypeothers', 'Nothing. Just wanna say hi'],
1098
            [true, api::DATAREQUEST_TYPE_EXPORT, 'requesttypeexport', 'Admin export data of another user'],
1098
            [true, api::DATAREQUEST_TYPE_EXPORT, 'requesttypeexport', 'Admin export data of another user'],
Línea 1440... Línea 1440...
1440
    }
1440
    }
Línea 1441... Línea 1441...
1441
 
1441
 
1442
    /**
1442
    /**
1443
     * Data provider for invalid contextlevel fetchers.
1443
     * Data provider for invalid contextlevel fetchers.
1444
     */
1444
     */
1445
    public function invalid_effective_contextlevel_provider() {
1445
    public static function invalid_effective_contextlevel_provider(): array {
1446
        return [
1446
        return [
1447
            [CONTEXT_COURSECAT],
1447
            [CONTEXT_COURSECAT],
1448
            [CONTEXT_COURSE],
1448
            [CONTEXT_COURSE],
1449
            [CONTEXT_MODULE],
1449
            [CONTEXT_MODULE],
Línea 2000... Línea 2000...
2000
    }
2000
    }
Línea 2001... Línea 2001...
2001
 
2001
 
2002
    /**
2002
    /**
2003
     * Data provider for \tool_dataprivacy_api_testcase::test_set_context_defaults
2003
     * Data provider for \tool_dataprivacy_api_testcase::test_set_context_defaults
2004
     */
2004
     */
2005
    public function set_context_defaults_provider() {
2005
    public static function set_context_defaults_provider(): array {
2006
        $contextlevels = [
2006
        $contextlevels = [
2007
            [CONTEXT_COURSECAT],
2007
            [CONTEXT_COURSECAT],
2008
            [CONTEXT_COURSE],
2008
            [CONTEXT_COURSE],
2009
            [CONTEXT_MODULE],
2009
            [CONTEXT_MODULE],
Línea 2163... Línea 2163...
2163
     * @param   string  $system Retention policy for the system.
2163
     * @param   string  $system Retention policy for the system.
2164
     * @param   string  $user Retention policy for users.
2164
     * @param   string  $user Retention policy for users.
2165
     * @param   string  $course Retention policy for courses.
2165
     * @param   string  $course Retention policy for courses.
2166
     * @param   string  $activity Retention policy for activities.
2166
     * @param   string  $activity Retention policy for activities.
2167
     */
2167
     */
2168
    protected function setup_basics(string $system, string $user, string $course = null, string $activity = null): \stdClass {
2168
    protected function setup_basics(string $system, string $user, ?string $course = null, ?string $activity = null): \stdClass {
2169
        $this->resetAfterTest();
2169
        $this->resetAfterTest();
Línea 2170... Línea 2170...
2170
 
2170
 
2171
        $purposes = (object) [
2171
        $purposes = (object) [
2172
            'system' => $this->create_and_set_purpose_for_contextlevel($system, CONTEXT_SYSTEM),
2172
            'system' => $this->create_and_set_purpose_for_contextlevel($system, CONTEXT_SYSTEM),
Línea 2475... Línea 2475...
2475
    /**
2475
    /**
2476
     * Data provider function for testing \tool_dataprivacy\api::queue_data_request_task().
2476
     * Data provider function for testing \tool_dataprivacy\api::queue_data_request_task().
2477
     *
2477
     *
2478
     * @return array
2478
     * @return array
2479
     */
2479
     */
2480
    public function queue_data_request_task_provider() {
2480
    public static function queue_data_request_task_provider(): array {
2481
        return [
2481
        return [
2482
            'With user ID provided' => [true],
2482
            'With user ID provided' => [true],
2483
            'Without user ID provided' => [false],
2483
            'Without user ID provided' => [false],
2484
        ];
2484
        ];
2485
    }
2485
    }
Línea 2512... Línea 2512...
2512
    }
2512
    }
Línea 2513... Línea 2513...
2513
 
2513
 
2514
    /**
2514
    /**
2515
     * Data provider for test_is_automatic_request_approval_on().
2515
     * Data provider for test_is_automatic_request_approval_on().
2516
     */
2516
     */
2517
    public function automatic_request_approval_setting_provider() {
2517
    public static function automatic_request_approval_setting_provider(): array {
2518
        return [
2518
        return [
2519
            'Data export, not set' => [
2519
            'Data export, not set' => [
2520
                'automaticdataexportapproval', api::DATAREQUEST_TYPE_EXPORT, null, false
2520
                'automaticdataexportapproval', api::DATAREQUEST_TYPE_EXPORT, null, false
2521
            ],
2521
            ],