Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea -...
16
 
-
 
17
/**
-
 
18
 * Base class for unit tests for mod_assign.
-
 
19
 *
-
 
20
 * @package    mod_assign
-
 
21
 * @copyright  2018 Adrian Greeve <adrian@moodle.com>
-
 
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
23
 */
-
 
24
 
16
 
Línea 25... Línea -...
25
namespace mod_assign\privacy;
-
 
26
 
-
 
27
defined('MOODLE_INTERNAL') || die();
-
 
28
 
-
 
29
global $CFG;
-
 
30
require_once($CFG->dirroot . '/mod/assign/locallib.php');
-
 
31
 
17
namespace mod_assign\privacy;
32
use core_privacy\tests\provider_testcase;
18
 
33
use core_privacy\local\request\writer;
19
use core_privacy\local\request\writer;
-
 
20
use core_privacy\local\request\approved_contextlist;
Línea 34... Línea 21...
34
use core_privacy\local\request\approved_contextlist;
21
use mod_assign\privacy\provider;
35
use mod_assign\privacy\provider;
22
use mod_assign\tests\provider_testcase;
36
 
23
 
-
 
24
/**
37
/**
25
 * Unit tests for mod/assign/classes/privacy/
38
 * Unit tests for mod/assign/classes/privacy/
26
 *
-
 
27
 * @package    mod_assign
39
 *
28
 * @copyright  2018 Adrian Greeve <adrian@moodle.com>
40
 * @copyright  2018 Adrian Greeve <adrian@moodle.com>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-
 
42
 */
-
 
43
class provider_test extends provider_testcase {
-
 
44
 
-
 
45
    /**
-
 
46
     * Convenience method for creating a submission.
-
 
47
     *
-
 
48
     * @param  assign  $assign The assign object
-
 
49
     * @param  stdClass  $user The user object
-
 
50
     * @param  string  $submissiontext Submission text
-
 
51
     * @param  integer $attemptnumber The attempt number
-
 
52
     * @return object A submission object.
-
 
53
     */
-
 
54
    protected function create_submission($assign, $user, $submissiontext, $attemptnumber = 0) {
-
 
55
        $submission = $assign->get_user_submission($user->id, true, $attemptnumber);
-
 
56
        $submission->onlinetext_editor = ['text' => $submissiontext,
-
 
57
                                         'format' => FORMAT_MOODLE];
-
 
58
 
-
 
59
        $this->setUser($user);
-
 
60
        $notices = [];
-
 
61
        $assign->save_submission($submission, $notices);
-
 
62
        return $submission;
-
 
63
    }
-
 
64
 
-
 
65
    /**
-
 
66
     * Convenience function to create an instance of an assignment.
-
 
67
     *
-
 
68
     * @param array $params Array of parameters to pass to the generator
-
 
69
     * @return assign The assign class.
-
 
70
     */
-
 
71
    protected function create_instance($params = array()) {
-
 
72
        $generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
-
 
73
        $instance = $generator->create_instance($params);
-
 
74
        $cm = get_coursemodule_from_instance('assign', $instance->id);
-
 
75
        $context = \context_module::instance($cm->id);
-
 
76
        return new \assign($context, $cm, $params['course']);
30
 * @covers \mod_assign\privacy\provider
77
    }
31
 */
78
 
32
final class provider_test extends provider_testcase {
79
    /**
33
    /**
80
     * Test that getting the contexts for a user works.
34
     * Test that getting the contexts for a user works.