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
.
namespace mod_wiki;
use wiki_parser_proxy;
defined('MOODLE_INTERNAL') || die;
global $CFG;
require_once($CFG->dirroot . '/mod/wiki/parser/parser.php');
/**
* Unit tests for the wiki parser
*
* @package mod_wiki
* @category test
* @copyright 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
* @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
*
* @author Jordi Piguillem
* @author Marc Alier
* @author David Jimenez
* @author Josep Arus
* @author Kenneth Riba
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class wikiparser_test extends \basic_testcase {
/**
* URL inside the clickable text of some link should not be turned into a new link via the url_tag_rule.
*
* @dataProvider urls_inside_link_text_provider
* @param string $markup Markup of the Wiki page the text is part of.
* @param string $input The input text.
* @param string $output The expected output HTML as a result of the parsed input text.
*/
public function test_urls_inside_link_text(string $markup, string $input, string $output) {
$parsingresult = wiki_parser_proxy::parse($input, $markup, [
'link_callback' => '/mod/wiki/locallib.php:wiki_parser_link',
'link_callback_args' => ['swid' => 1],
]);
$this->assertStringContainsString($output, $parsingresult['parsed_text']);
}
/**
* Provides data sets for {@see self::test_urls_inside_link_text()}.
*
* @return array
*/
public function urls_inside_link_text_provider() {
return [
'creole implicit link' => [
'markup' => 'creole',
'input' => 'Visit https://site.url for more information.',
'output' => 'Visit https://site.url for more information.',
],
'creole explicit link' => [
'markup' => 'creole',
'input' => 'Visit [[https://site.url]] for more information.',
'output' => 'Visit https://site.url for more information.',
],
'creole explicit link with text' => [
'markup' => 'creole',
'input' => 'Visit [[https://site.url|http://www.site.url]] for more information.',
'output' => 'Visit http://www.site.url for more information.',
],
'nwiki implicit link' => [
'markup' => 'nwiki',
'input' => 'Visit https://site.url for more information.',
'output' => 'Visit https://site.url for more information.',
],
'nwiki explicit link' => [
'markup' => 'nwiki',
'input' => 'Visit [https://site.url] for more information.',
'output' => 'Visit https://site.url for more information.',
],
'nwiki explicit link with space separated text' => [
'markup' => 'nwiki',
'input' => 'Visit [https://site.url http://www.site.url] for more information.',
'output' => 'Visit http://www.site.url for more information.',
],
'nwiki explicit link with pipe separated text' => [
'markup' => 'nwiki',
'input' => 'Visit [https://site.url|http://www.site.url] for more information.',
'output' => 'Visit http://www.site.url for more information.',
],
'html implicit link' => [
'markup' => 'html',
'input' => 'Visit https://site.url for more information.',
'output' => 'Visit https://site.url for more information.',
],
'html explicit link with text' => [
'markup' => 'html',
'input' => 'Visit http://www.site.url for more information.',
'output' => 'Visit http://www.site.url for more information.',
],
'html wiki link to non-existing page' => [
'markup' => 'html',
'input' => 'Visit [[Another page]] for more information.',
'output' => 'Visit ' .
'Another page for more information.',
],
'html wiki link inside an explicit link' => [
// The explicit href URL takes precedence here, the [[...]] is not turned into a wiki link.
'markup' => 'html',
'input' => 'Visit [[Another page]] for more information.',
'output' => 'Visit [[Another page]] for more information.',
],
];
}
function testCreoleMarkup() {
$this->assertTestFiles('creole');
}
function testNwikiMarkup() {
$this->assertTestFiles('nwiki');
}
function testHtmlMarkup() {
$this->assertTestFiles('html');
}
private function assertTestFile($num, $markup) {
if(!file_exists(__DIR__."/fixtures/input/$markup/$num") || !file_exists(__DIR__."/fixtures/output/$markup/$num")) {
return false;
}
$input = file_get_contents(__DIR__."/fixtures/input/$markup/$num");
$output = file_get_contents(__DIR__."/fixtures/output/$markup/$num");
$result = wiki_parser_proxy::parse($input, $markup, array('pretty_print' => true));
//removes line breaks to avoid line break encoding causing tests to fail.
$result['parsed_text'] = preg_replace('~[\r\n]~', '', $result['parsed_text']);
$output = preg_replace('~[\r\n]~', '', $output);
$this->assertEquals($output, $result['parsed_text'], 'Failed asserting that two strings are equal. Markup = '.$markup.", num = $num");
return true;
}
private function assertTestFiles($markup) {
$i = 1;
while($this->assertTestFile($i, $markup)) {
$i++;
}
}
/**
* Check that headings with special characters work as expected with HTML.
*
* - The heading itself is well displayed,
* - The TOC heading is well display,
* - The edit link points to the right page,
* - The links properly works with get_section.
*/
public function test_special_headings() {
// First testing HTML markup.
// Test section name using HTML entities.
$input = '
';
$section = wiki_parser_proxy::get_section($input, 'creole', 'Another áéíóúç€ test');
$actual = wiki_parser_proxy::parse($input, 'creole');
$this->assertEquals($output, $actual['parsed_text']);
$this->assertEquals($toc, $actual['toc']);
$this->assertNotEquals(false, $section);
// Test section name with a URL, creole does not support linking links in a heading.
$input = '= Another http://moodle.org test =';
$output = '
';
$section = wiki_parser_proxy::get_section($input, 'creole', 'Another http://moodle.org test');
$actual = wiki_parser_proxy::parse($input, 'creole');
$this->assertEquals($output, $actual['parsed_text']);
$this->assertEquals($toc, $actual['toc']);
$this->assertNotEquals(false, $section);
// Now going to test NWiki markup.
// Note that Creole uses links to the escaped version of the section.
// Test section name using HTML entities.
$input = '= Code & Test =';
$output = '
';
$section = wiki_parser_proxy::get_section($input, 'nwiki', 'Another áéíóúç€ test');
$actual = wiki_parser_proxy::parse($input, 'nwiki');
$this->assertEquals($output, $actual['parsed_text']);
$this->assertEquals($toc, $actual['toc']);
$this->assertNotEquals(false, $section);
// Test section name with a URL, nwiki does not support linking links in a heading.
$input = '= Another http://moodle.org test =';
$output = '