f980e203ad69969d1a2a17302c4ddab453d64fa0
[moodle.git] / mod / assignment / simpletest / test_assignment_portfolio_callers.php
1 <?php
2 require_once("$CFG->libdir/simpletest/portfolio_testclass.php");
3 require_once("$CFG->dirroot/mod/assignment/lib.php");
4 require_once("$CFG->dirroot/$CFG->admin/generator.php");
6 Mock::generate('assignment_portfolio_caller', 'mock_caller');
7 Mock::generate('portfolio_exporter', 'mock_exporter');
9 class testAssignmentPortfolioCallers extends portfoliolib_test {
10     public static $includecoverage = array('lib/portfoliolib.php', 'mod/assignment/lib.php');
11     public $module_type = 'assignment';
12     public $modules = array();
13     public $entries = array();
14     public $caller;
16     public function setUp() {
17         global $DB, $USER;
19         parent::setUp();
20         $assignment_types = new stdClass();
21         $assignment_types->type = GENERATOR_SEQUENCE;
22         $assignment_types->options = array('online');
24         $settings = array('quiet' => 1,
25                           'modules_list' => array($this->module_type), 'assignment_grades' => true,
26                           'assignment_type' => $assignment_types,
27                           'number_of_students' => 5, 'students_per_course' => 5, 'number_of_sections' => 1,
28                           'number_of_modules' => 3, 'questions_per_course' => 0);
30         generator_generate_data($settings);
32         $this->modules = $DB->get_records($this->module_type);
33         $first_module = reset($this->modules);
34         $cm = get_coursemodule_from_instance($this->module_type, $first_module->id);
35         $submissions = $DB->get_records('assignment_submissions', array('assignment' => $first_module->id));
36         $first_submission = reset($submissions);
38         $this->caller = parent::setup_caller('assignment_portfolio_caller', array('id' => $cm->id), $first_submission->userid);
39     }
41     public function tearDown() {
42         parent::tearDown();
43     }
45     public function test_caller_sha1() {
46         $sha1 = $this->caller->get_sha1();
47         $this->caller->prepare_package();
48         $this->assertEqual($sha1, $this->caller->get_sha1());
49     }
51     public function test_caller_with_plugins() {
52         parent::test_caller_with_plugins();
53     }
54 }