Unit tests MDL-24981 Fixed portfolio unit test so it at least runs (albeit with 23...
[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");
5 require_once("$CFG->dirroot/mod/assignment/locallib.php");
7 Mock::generate('assignment_portfolio_caller', 'mock_caller');
8 Mock::generate('portfolio_exporter', 'mock_exporter');
10 class testAssignmentPortfolioCallers extends portfoliolib_test {
11     public static $includecoverage = array('lib/portfoliolib.php', 'mod/assignment/lib.php');
12     public $module_type = 'assignment';
13     public $modules = array();
14     public $entries = array();
15     public $caller;
17     public function setUp() {
18         global $DB, $USER;
20         parent::setUp();
21         $assignment_types = new stdClass();
22         $assignment_types->type = GENERATOR_SEQUENCE;
23         $assignment_types->options = array('online');
25         $settings = array('quiet' => 1,
26                           'modules_list' => array($this->module_type), 'assignment_grades' => true,
27                           'assignment_type' => $assignment_types,
28                           'number_of_students' => 5, 'students_per_course' => 5, 'number_of_sections' => 1,
29                           'number_of_modules' => 3, 'questions_per_course' => 0);
31         generator_generate_data($settings);
33         $this->modules = $DB->get_records($this->module_type);
34         $first_module = reset($this->modules);
35         $cm = get_coursemodule_from_instance($this->module_type, $first_module->id);
36         $submissions = $DB->get_records('assignment_submissions', array('assignment' => $first_module->id));
37         $first_submission = reset($submissions);
39         $this->caller = parent::setup_caller('assignment_portfolio_caller', array('id' => $cm->id), $first_submission->userid);
40     }
42     public function tearDown() {
43         parent::tearDown();
44     }
46     public function test_caller_sha1() {
47         $sha1 = $this->caller->get_sha1();
48         $this->caller->prepare_package();
49         $this->assertEqual($sha1, $this->caller->get_sha1());
50     }
52     public function test_caller_with_plugins() {
53         parent::test_caller_with_plugins();
54     }
55 }