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
. /** * Unit test for the filter_mediaplugin * * @package filter_mediaplugin * @category phpunit * @copyright 2011 Rossiani Wijaya * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace filter_mediaplugin; use filter_mediaplugin; defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/filter/mediaplugin/filter.php'); // Include the code to test class filter_test extends \advanced_testcase { function test_filter_mediaplugin_link() { $this->resetAfterTest(true); // We need to enable the media plugins. \core\plugininfo\media::set_enabled_plugins('vimeo,youtube,videojs,html5video,html5audio'); $filterplugin = new filter_mediaplugin(null, array()); $longurl = 'my test file'; $longhref = ''; do { $longhref .= 'a'; } while(strlen($longhref) + strlen($longurl) < 4095); $longurl = 'my test file'; $validtexts = array ( 'test mp3', 'test ogg', 'test mp4', 'test', 'test file', 'test file', 'test file', 'test file', 'test file', 'test file', 'test ogg', 'test mp3', 'test mp3', 'test mp3', 'youtube\'s', ' test mp3', 'test wav ', 'youtube\'s', // Test a long URL under 4096 characters. $longurl ); //test for valid link foreach ($validtexts as $text) { $msg = "Testing text: ". $text; $filter = $filterplugin->filter($text); $this->assertNotEquals($text, $filter, $msg); } $insertpoint = strrpos($longurl, 'http://'); $longurl = substr_replace($longurl, 'http://pushover4096chars', $insertpoint, 0); $originalurl = '

Some text.

' .
            'Valid link
';
        $paddedurl = str_pad($originalurl, 6000, 'z');
        $validpaddedurl = '

Some text.



';
        $validpaddedurl = str_pad($validpaddedurl, 6000 + (strlen($validpaddedurl) - strlen($originalurl)), 'z');

        $invalidtexts = array(
            'href="http://moodle.org/testfile/test.mp3"',
            'test test',
            'test test',
            'test test',
            'test test',
            'sample',
            '',
            'test',
            'test mp3',
            '',
            'test',
            'test',
            'test mp3',
            'test mp3',
            'test mp3',
            // Test a long URL over 4096 characters.
            $longurl
        );

        //test for invalid link
        foreach ($invalidtexts as $text) {
            $msg = "Testing text: ". $text;
            $filter = $filterplugin->filter($text);
            $this->assertEquals($text, $filter, $msg);
        }

        // Valid mediaurl followed by a longurl.
        $precededlongurl = 'test.mp3'. $longurl;
        $filter = $filterplugin->filter($precededlongurl);
        $this->assertEquals(1, substr_count($filter, ''));
        $this->assertStringContainsString($longurl, $filter);

        // Testing for cases where: to be filtered content has 6+ text afterwards.
        $filter = $filterplugin->filter($paddedurl);
        $this->assertEquals($validpaddedurl, $filter, $msg);
    }
}