Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 namespace core; 18 19 /** 20 * Unit tests for the xhprof class. 21 * 22 * @package core 23 * @category test 24 * @copyright 2019 Brendan Heywood <brendan@catalyst-au.net> 25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 26 */ 27 class xhprof_test extends \advanced_testcase { 28 29 /** 30 * Data provider for string matches 31 * 32 * @return array 33 */ 34 public function profiling_string_matches_provider() { 35 return [ 36 ['/index.php', '/index.php', true], 37 ['/some/dir/index.php', '/index.php', false], 38 ['/course/view.php', '/course/view.php', true], 39 ['/view.php', '/course/view.php', false], 40 ['/mod/forum', '/mod/forum/*', false], 41 ['/mod/forum/', '/mod/forum/*', true], 42 ['/mod/forum/index.php', '/mod/forum/*', true], 43 ['/mod/forum/foo.php', '/mod/forum/*', true], 44 ['/mod/forum/view.php', '/mod/*/view.php', true], 45 ['/mod/one/two/view.php', '/mod/*/view.php', true], 46 ['/view.php', '*/view.php', true], 47 ['/mod/one/two/view.php', '*/view.php', true], 48 ['/foo.php', '/foo.php,/bar.php', true], 49 ['/bar.php', '/foo.php,/bar.php', true], 50 ['/foo/bar.php', "/foo.php,/bar.php", false], 51 ['/foo/bar.php', "/foo.php,*/bar.php", true], 52 ['/foo/bar.php', "/foo*.php,/bar.php", true], 53 ['/foo.php', "/foo.php\n/bar.php", true], 54 ['/bar.php', "/foo.php\n/bar.php", true], 55 ['/foo/bar.php', "/foo.php\n/bar.php", false], 56 ['/foo/bar.php', "/foo.php\n*/bar.php", true], 57 ['/foo/bar.php', "/foo*.php\n/bar.php", true], 58 ]; 59 } 60 61 /** 62 * Test the matching syntax 63 * 64 * @dataProvider profiling_string_matches_provider 65 * @param string $string 66 * @param string $patterns 67 * @param bool $expected 68 */ 69 public function test_profiling_string_matches($string, $patterns, $expected) { 70 71 global $CFG; 72 require_once($CFG->libdir . '/xhprof/xhprof_moodle.php'); 73 74 $result = profiling_string_matches($string, $patterns); 75 $this->assertSame($result, $expected); 76 } 77 78 } 79
title
Description
Body
title
Description
Body
title
Description
Body
title
Body