Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231
.
/**
* This file contains unit test related to xAPI library.
*
* @package core_xapi
* @copyright 2020 Ferran Recio
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_xapi;
use advanced_testcase;
defined('MOODLE_INTERNAL') || die();
/**
* Contains test cases for testing xAPI iri class.
*
* @package core_xapi
* @since Moodle 3.9
* @copyright 2020 Ferran Recio
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class iri_test extends advanced_testcase {
/**
* Setup to ensure that fixtures are loaded.
*/
public static function setupBeforeClass(): void {
global $CFG;
require_once($CFG->dirroot.'/lib/xapi/tests/helper.php');
}
/**
* Test IRI generation.
*
* @dataProvider iri_samples_provider
* @param string $value Value to generate IRI
* @param string $expected Expected result
* @param string $type = null If some special type is provided
*/
public function test_generate(string $value, string $expected, string $type = null) {
$iri = iri::generate($value, $type);
$this->assertEquals($iri, $expected);
}
/**
* Test IRI extraction.
*
* @dataProvider iri_samples_provider
* @param string $expected Expected result
* @param string $value Value to generate IRI
* @param string $type = null If some special type is provided
*/
public function test_extract(string $expected, string $value, string $type = null) {
$extract = iri::extract($value, $type);
$this->assertEquals($extract, $expected);
}
/**
* Data provider for the test_generate and test_extract tests.
*
* @return array
*/
public function iri_samples_provider() : array {
global $CFG;
return [
'Fake IRI without type' => [
'paella',
"{$CFG->wwwroot}/xapi/element/paella",
null,
],
'Real IRI without type' => [
'http://adlnet.gov/expapi/activities/example',
'http://adlnet.gov/expapi/activities/example',
null,
],
'Fake IRI with type' => [
'paella',
"{$CFG->wwwroot}/xapi/dish/paella",
'dish',
],
'Real IRI with type' => [
'http://adlnet.gov/expapi/activities/example',
'http://adlnet.gov/expapi/activities/example',
'dish',
],
];
}
/**
* Test IRI generation.
*
* @dataProvider iri_check_provider
* @param string $value Value to generate IRI
* @param bool $expected Expected result
*/
public function test_check(string $value, bool $expected) {
$check = iri::check($value);
$this->assertEquals($check, $expected);
}
/**
* Data provider for the test_check.
*
* @return array
*/
public function iri_check_provider() : array {
return [
'Real IRI http' => [
'http://adlnet.gov/expapi/activities/example',
true,
],
'Real IRI https' => [
'https://adlnet.gov/expapi/activities/example',
true,
],
'Invalid IRI' => [
'paella',
false,
],
];
}
}