forked from adlnet/moodle-logstore_xapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfailed_report_test.php
115 lines (94 loc) · 3.91 KB
/
failed_report_test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace logstore_xapi;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/admin/tool/log/store/xapi/tests/enchancement_jisc_skeleton.php');
require_once($CFG->dirroot . '/admin/tool/log/store/xapi/classes/form/reportfilter_form.php');
/**
* Test case for failed events in a report.
*
* @package logstore_xapi
* @author László Záborski <[email protected]>
* @copyright 2020 Learning Pool Ltd (http://learningpool.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class failed_report_test extends enchancement_jisc_skeleton {
/**
* @var array Simulated submitted reportfilter_form data for failed report.
*/
protected $simulatedsubmitteddata = [
'id' => XAPI_REPORT_ID_ERROR,
'resend' => XAPI_REPORT_RESEND_FALSE,
'errortype' => XAPI_REPORT_ERROTYPE_DEFAULT,
'eventnames' => ['\core\event\course_viewed'],
'response' => XAPI_REPORT_RESPONSE_DEFAULT,
'datefrom' => 0,
'dateto' => 0,
'submitbutton' => 'Search'
];
/**
* Get submitted and validated form.
*
* @return tool_logstore_xapi_reportfilter_form
*/
protected function get_validated_form() {
$filterparams = [
'defaults' => $this->formdefaults,
'reportid' => XAPI_REPORT_ID_ERROR,
'eventnames' => logstore_xapi_get_event_names_array(),
'errortypes' => logstore_xapi_get_distinct_options_from_failed_table('errortype'),
'responses' => logstore_xapi_get_distinct_options_from_failed_table('response')
];
$form = new form\tool_logstore_xapi_reportfilter_form('', $filterparams);
$this->assertTrue($form->is_validated());
$this->assertTrue($form->is_submitted());
return $form;
}
/**
* Creating minimum a single course view event to xapi logstore.
* Submit form and validate form data.
*
* @covers \form\tool_logstore_xapi_reportfilter_form
*/
public function test_single_element() {
$this->markTestSkipped('must be revisited.');
global $DB;
parent::test_single_element();
$records = $DB->get_records('logstore_xapi_failed_log');
$this->assertCount($this->generatedxapilog, $records);
form\tool_logstore_xapi_reportfilter_form::mock_submit($this->simulatedsubmitteddata);
$form = $this->get_validated_form();
$this->validate_submitted_data($form->get_data());
}
/**
* Creating multiple course view events to xapi logstore.
* Record number depends on $multipletestnumber.
* Submit form and validate form data.
*
* @covers \form\tool_logstore_xapi_reportfilter_form
*/
public function test_multiple_elements() {
$this->markTestSkipped('must be revisited.');
global $DB;
parent::test_multiple_elements();
$records = $DB->get_records('logstore_xapi_failed_log');
$this->assertCount($this->multipletestnumber * $this->generatedxapilog, $records);
form\tool_logstore_xapi_reportfilter_form::mock_submit($this->simulatedsubmitteddata);
$form = $this->get_validated_form();
$this->validate_submitted_data($form->get_data());
}
}