See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 39 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Unit test for the filter_algebra 19 * 20 * @package filter_algebra 21 * @category phpunit 22 * @copyright 2012 Tim Hunt 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 namespace filter_algebra; 27 28 use filter_algebra; 29 30 defined('MOODLE_INTERNAL') || die(); 31 32 global $CFG; 33 require_once($CFG->dirroot . '/filter/algebra/filter.php'); 34 35 36 /** 37 * Unit tests for filter_algebra. 38 * 39 * Note that this only tests some of the filter logic. It does not actually test 40 * the normal case of the filter working, because I cannot make it work on my 41 * test server, and if it does not work here, it probably does not also work 42 * for other people. A failing test will be irritating noise. 43 * 44 * @copyright 2012 Tim Hunt 45 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 46 */ 47 class filter_test extends \basic_testcase { 48 49 protected $filter; 50 51 protected function setUp(): void { 52 parent::setUp(); 53 $this->filter = new filter_algebra(\context_system::instance(), array()); 54 } 55 56 function test_algebra_filter_no_algebra() { 57 $this->assertEquals('<p>Look no algebra!</p>', 58 $this->filter->filter('<p>Look no algebra!</p>')); 59 } 60 61 62 function test_algebra_filter_pluginfile() { 63 $this->assertEquals('<img src="@@PLUGINFILE@@/photo.jpg">', 64 $this->filter->filter('<img src="@@PLUGINFILE@@/photo.jpg">')); 65 } 66 67 function test_algebra_filter_draftfile() { 68 $this->assertEquals('<img src="@@DRAFTFILE@@/photo.jpg">', 69 $this->filter->filter('<img src="@@DRAFTFILE@@/photo.jpg">')); 70 } 71 72 function test_algebra_filter_unified_diff() { 73 $diff = ' 74 diff -u -r1.1 Worksheet.php 75 --- Worksheet.php 26 Sep 2003 04:18:02 -0000 1.1 76 +++ Worksheet.php 18 Nov 2009 03:58:50 -0000 77 @@ -1264,10 +1264,10 @@ 78 } 79 80 // Strip the = or @ sign at the beginning of the formula string 81 - if (ereg("^=",$formula)) { 82 + if (preg_match("/^=/",$formula)) { 83 $formula = preg_replace("/(^=)/","",$formula); 84 } 85 - elseif(ereg("^@",$formula)) { 86 + elseif(preg_match("/^@/",$formula)) { 87 $formula = preg_replace("/(^@)/","",$formula); 88 } 89 else { 90 '; 91 $this->assertEquals('<pre>' . $diff . '</pre>', 92 $this->filter->filter('<pre>' . $diff . '</pre>')); 93 } 94 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body