2 require_once("$CFG->libdir/simpletest/portfolio_testclass.php");
3 require_once("$CFG->dirroot/mod/data/lib.php");
4 require_once("$CFG->dirroot/$CFG->admin/generator.php");
5 require_once("$CFG->dirroot/mod/data/locallib.php");
7 Mock::generate('data_portfolio_caller', 'mock_caller');
8 Mock::generate('portfolio_exporter', 'mock_exporter');
10 class testDataPortfolioCallers extends portfoliolib_test {
11 public static $includecoverage = array('lib/portfoliolib.php', 'mod/data/lib.php');
12 public $module_type = 'data';
13 public $modules = array();
14 public $entries = array();
15 public $caller_single;
18 public function setUp() {
23 $settings = array('quiet' => 1,
26 'modules_list' => array($this->module_type),
27 'number_of_students' => 5,
28 'students_per_course' => 5,
29 'number_of_sections' => 1,
30 'number_of_modules' => 1,
31 'questions_per_course' => 0);
33 generator_generate_data($settings);
35 $this->modules = $DB->get_records($this->module_type);
36 $first_module = reset($this->modules);
37 $cm = get_coursemodule_from_instance($this->module_type, $first_module->id);
39 $fields = $DB->get_records('data_fields', array('dataid' => $first_module->id));
40 $recordid = data_add_record($first_module);
41 foreach ($fields as $field) {
42 $content->recordid = $recordid;
43 $content->fieldid = $field->id;
44 $content->content = 'test content';
45 $content->content1 = 'test content 1';
46 $content->content2 = 'test content 2';
47 $DB->insert_record('data_content',$content);
50 // Callback args required: id, record, delimiter_name, exporttype
51 $this->caller_single = parent::setup_caller('data_portfolio_caller', array('id' => $cm->id, 'record' => $recordid));
52 $this->caller = parent::setup_caller('data_portfolio_caller', array('id' => $cm->id));
55 public function tearDown() {
59 public function test_caller_sha1() {
60 $sha1 = $this->caller->get_sha1();
61 $this->caller->prepare_package();
62 $this->assertEqual($sha1, $this->caller->get_sha1());
64 $sha1 = $this->caller_single->get_sha1();
65 $this->caller_single->prepare_package();
66 $this->assertEqual($sha1, $this->caller_single->get_sha1());
69 public function test_caller_with_plugins() {
70 parent::test_caller_with_plugins();