See Release Notes
Long Term Support Release
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 tests for search events. 19 * 20 * @package core_search 21 * @category phpunit 22 * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 /** 29 * Unit tests for search events. 30 * 31 * @package core_search 32 * @category phpunit 33 * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class core_search_events_testcase extends advanced_testcase { 37 38 /** 39 * test_search_results_viewed 40 * 41 * @return void 42 */ 43 public function test_search_results_viewed() { 44 45 $this->resetAfterTest(); 46 47 $user = $this->getDataGenerator()->create_user(); 48 $this->setUser($user); 49 50 $sink = $this->redirectEvents(); 51 52 // Basic event. 53 \core_search\manager::trigger_search_results_viewed([ 54 'q' => 'I am a query', 55 'page' => 0, 56 ]); 57 58 $events = $sink->get_events(); 59 $event = reset($events); 60 $sink->clear(); 61 62 $this->assertEquals(context_system::instance(), $event->get_context()); 63 64 $urlparams = ['q' => 'I am a query', 'page' => 0]; 65 $this->assertEquals($urlparams, $event->get_url()->params()); 66 67 \core_search\manager::trigger_search_results_viewed([ 68 'q' => 'I am a query', 69 'page' => 2, 70 'title' => 'I am the title', 71 'areaids' => array(3,4,5), 72 'courseids' => array(2,3), 73 'timestart' => 1445644800, 74 'timeend' => 1477267200 75 ]); 76 77 $events = $sink->get_events(); 78 $event = reset($events); 79 $this->assertEquals(context_system::instance(), $event->get_context()); 80 81 $urlparams = ['q' => 'I am a query', 'page' => 2, 'title' => 'I am the title', 'timestart' => 1445644800, 'timeend' => 1477267200]; 82 $this->assertEquals($urlparams, $event->get_url()->params()); 83 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body