1adbd2c3 |
1 | <?php |
d1aa1e48 |
2 | require_once("$CFG->libdir/simpletest/portfolio_testclass.php"); |
cc4245a3 |
3 | require_once("$CFG->dirroot/mod/data/lib.php"); |
d1aa1e48 |
4 | require_once("$CFG->dirroot/$CFG->admin/generator.php"); |
bf81b168 |
5 | require_once("$CFG->dirroot/mod/data/locallib.php"); |
d5849d59 |
6 | |
7 | Mock::generate('data_portfolio_caller', 'mock_caller'); |
8 | Mock::generate('portfolio_exporter', 'mock_exporter'); |
9 | |
10 | class testDataPortfolioCallers extends portfoliolib_test { |
ce40c8ff |
11 | public static $includecoverage = array('lib/portfoliolib.php', 'mod/data/lib.php'); |
d5849d59 |
12 | public $module_type = 'data'; |
13 | public $modules = array(); |
14 | public $entries = array(); |
f968a736 |
15 | public $caller_single; |
d5849d59 |
16 | public $caller; |
17 | |
18 | public function setUp() { |
19 | global $DB, $USER; |
20 | |
21 | parent::setUp(); |
22 | |
23 | $settings = array('quiet' => 1, |
795ad630 |
24 | |
d5849d59 |
25 | 'pre_cleanup' => 0, |
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); |
32 | |
33 | generator_generate_data($settings); |
34 | |
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); |
38 | |
f968a736 |
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); |
48 | } |
49 | |
d5849d59 |
50 | // Callback args required: id, record, delimiter_name, exporttype |
27dda89f |
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)); |
d5849d59 |
53 | } |
54 | |
55 | public function tearDown() { |
56 | parent::tearDown(); |
57 | } |
58 | |
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()); |
f968a736 |
63 | |
64 | $sha1 = $this->caller_single->get_sha1(); |
65 | $this->caller_single->prepare_package(); |
66 | $this->assertEqual($sha1, $this->caller_single->get_sha1()); |
d5849d59 |
67 | } |
68 | |
795ad630 |
69 | public function test_caller_with_plugins() { |
70 | parent::test_caller_with_plugins(); |
71 | } |
d5849d59 |
72 | } |
1adbd2c3 |
73 | |