Línea 23... |
Línea 23... |
23 |
* @copyright 2018 Mihail Geshoski
|
23 |
* @copyright 2018 Mihail Geshoski
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
25 |
*/
|
25 |
*/
|
26 |
class digital_consent_test extends \advanced_testcase {
|
26 |
class digital_consent_test extends \advanced_testcase {
|
Línea 27... |
Línea 27... |
27 |
|
27 |
|
28 |
public function test_is_age_digital_consent_verification_enabled() {
|
28 |
public function test_is_age_digital_consent_verification_enabled(): void {
|
29 |
global $CFG;
|
29 |
global $CFG;
|
Línea 30... |
Línea 30... |
30 |
$this->resetAfterTest();
|
30 |
$this->resetAfterTest();
|
31 |
|
31 |
|
Línea 32... |
Línea 32... |
32 |
// Age of digital consent verification is enabled.
|
32 |
// Age of digital consent verification is enabled.
|
33 |
$CFG->agedigitalconsentverification = 0;
|
33 |
$CFG->agedigitalconsentverification = 0;
|
34 |
|
34 |
|
Línea 35... |
Línea 35... |
35 |
$isenabled = \core_auth\digital_consent::is_age_digital_consent_verification_enabled();
|
35 |
$isenabled = \core_auth\digital_consent::is_age_digital_consent_verification_enabled();
|
36 |
$this->assertFalse($isenabled);
|
36 |
$this->assertFalse($isenabled);
|
37 |
}
|
37 |
}
|
Línea 38... |
Línea 38... |
38 |
|
38 |
|
39 |
public function test_is_minor() {
|
39 |
public function test_is_minor(): void {
|
Línea 67... |
Línea 67... |
67 |
// Test country does not exists in agedigitalconsentmap and user age is above the particular digital minor age.
|
67 |
// Test country does not exists in agedigitalconsentmap and user age is above the particular digital minor age.
|
68 |
$isminor = \core_auth\digital_consent::is_minor($userage3, $usercountry2);
|
68 |
$isminor = \core_auth\digital_consent::is_minor($userage3, $usercountry2);
|
69 |
$this->assertFalse($isminor);
|
69 |
$this->assertFalse($isminor);
|
70 |
}
|
70 |
}
|
Línea 71... |
Línea 71... |
71 |
|
71 |
|
Línea 72... |
Línea 72... |
72 |
public function test_parse_age_digital_consent_map_valid_format() {
|
72 |
public function test_parse_age_digital_consent_map_valid_format(): void {
|
73 |
|
73 |
|
74 |
// Value of agedigitalconsentmap has a valid format.
|
74 |
// Value of agedigitalconsentmap has a valid format.
|
75 |
$agedigitalconsentmap = implode(PHP_EOL, [
|
75 |
$agedigitalconsentmap = implode(PHP_EOL, [
|
Línea 86... |
Línea 86... |
86 |
'BE' => 13
|
86 |
'BE' => 13
|
87 |
], $ageconsentmapparsed
|
87 |
], $ageconsentmapparsed
|
88 |
);
|
88 |
);
|
89 |
}
|
89 |
}
|
Línea 90... |
Línea 90... |
90 |
|
90 |
|
Línea 91... |
Línea 91... |
91 |
public function test_parse_age_digital_consent_map_invalid_format_missing_spaces() {
|
91 |
public function test_parse_age_digital_consent_map_invalid_format_missing_spaces(): void {
|
92 |
|
92 |
|
93 |
// Value of agedigitalconsentmap has an invalid format (missing space separator between values).
|
93 |
// Value of agedigitalconsentmap has an invalid format (missing space separator between values).
|
94 |
$agedigitalconsentmap = implode(PHP_EOL, [
|
94 |
$agedigitalconsentmap = implode(PHP_EOL, [
|
Línea 100... |
Línea 100... |
100 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidcomma', 'error', 'AT14'));
|
100 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidcomma', 'error', 'AT14'));
|
Línea 101... |
Línea 101... |
101 |
|
101 |
|
102 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
102 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
Línea 103... |
Línea 103... |
103 |
}
|
103 |
}
|
Línea 104... |
Línea 104... |
104 |
|
104 |
|
105 |
public function test_parse_age_digital_consent_map_invalid_format_missing_default_value() {
|
105 |
public function test_parse_age_digital_consent_map_invalid_format_missing_default_value(): void {
|
106 |
|
106 |
|
107 |
// Value of agedigitalconsentmap has an invalid format (missing default value).
|
107 |
// Value of agedigitalconsentmap has an invalid format (missing default value).
|
Línea 114... |
Línea 114... |
114 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvaliddefault', 'error'));
|
114 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvaliddefault', 'error'));
|
Línea 115... |
Línea 115... |
115 |
|
115 |
|
116 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
116 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
Línea 117... |
Línea 117... |
117 |
}
|
117 |
}
|
Línea 118... |
Línea 118... |
118 |
|
118 |
|
119 |
public function test_parse_age_digital_consent_map_invalid_format_invalid_country() {
|
119 |
public function test_parse_age_digital_consent_map_invalid_format_invalid_country(): void {
|
120 |
|
120 |
|
121 |
// Value of agedigitalconsentmap has an invalid format (invalid value for country).
|
121 |
// Value of agedigitalconsentmap has an invalid format (invalid value for country).
|
Línea 128... |
Línea 128... |
128 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidcountry', 'error', 'TEST'));
|
128 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidcountry', 'error', 'TEST'));
|
Línea 129... |
Línea 129... |
129 |
|
129 |
|
130 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
130 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
Línea 131... |
Línea 131... |
131 |
}
|
131 |
}
|
Línea 132... |
Línea 132... |
132 |
|
132 |
|
133 |
public function test_parse_age_digital_consent_map_invalid_format_invalid_age_string() {
|
133 |
public function test_parse_age_digital_consent_map_invalid_format_invalid_age_string(): void {
|
134 |
|
134 |
|
135 |
// Value of agedigitalconsentmap has an invalid format (string value for age).
|
135 |
// Value of agedigitalconsentmap has an invalid format (string value for age).
|
Línea 142... |
Línea 142... |
142 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidage', 'error', 'ten'));
|
142 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidage', 'error', 'ten'));
|
Línea 143... |
Línea 143... |
143 |
|
143 |
|
144 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
144 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
Línea 145... |
Línea 145... |
145 |
}
|
145 |
}
|
Línea 146... |
Línea 146... |
146 |
|
146 |
|
147 |
public function test_parse_age_digital_consent_map_invalid_format_missing_age() {
|
147 |
public function test_parse_age_digital_consent_map_invalid_format_missing_age(): void {
|
148 |
|
148 |
|
149 |
// Value of agedigitalconsentmap has an invalid format (missing value for age).
|
149 |
// Value of agedigitalconsentmap has an invalid format (missing value for age).
|
Línea 156... |
Línea 156... |
156 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidage', 'error', ''));
|
156 |
$this->expectExceptionMessage(get_string('agedigitalconsentmapinvalidage', 'error', ''));
|
Línea 157... |
Línea 157... |
157 |
|
157 |
|
158 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
158 |
\core_auth\digital_consent::parse_age_digital_consent_map($agedigitalconsentmap);
|
Línea 159... |
Línea 159... |
159 |
}
|
159 |
}
|
Línea 160... |
Línea 160... |
160 |
|
160 |
|
161 |
public function test_parse_age_digital_consent_map_invalid_format_missing_country() {
|
161 |
public function test_parse_age_digital_consent_map_invalid_format_missing_country(): void {
|
162 |
|
162 |
|
163 |
// Value of agedigitalconsentmap has an invalid format (missing value for country).
|
163 |
// Value of agedigitalconsentmap has an invalid format (missing value for country).
|