Differences Between: [Versions 311 and 402] [Versions 311 and 403]
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 helper for xAPI library. 19 * 20 * This file contains unit test helpers related to xAPI library. 21 * 22 * @package core_xapi 23 * @copyright 2020 Ferran Recio 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 namespace core_xapi; 27 28 use stdClass; 29 30 defined('MOODLE_INTERNAL') || die(); 31 32 require_once (__DIR__ . '/fixtures/handler.php'); 33 require_once (__DIR__ . '/fixtures/xapi_test_statement_post.php'); 34 35 /** 36 * Contains helper functions for xAPI PHPUnit Tests. 37 * 38 * @package core_xapi 39 * @since Moodle 3.9 40 * @copyright 2020 Ferran Recio 41 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 42 */ 43 class test_helper { 44 45 /** @var \core\log\reader contains a valid logstore reader. */ 46 private $store; 47 48 /** 49 * Constructor for a xAPI test helper. 50 * 51 */ 52 public function init_log() { 53 // Enable logs. 54 set_config('jsonformat', 1, 'logstore_standard'); 55 set_config('enabled_stores', 'logstore_standard', 'tool_log'); 56 set_config('buffersize', 0, 'logstore_standard'); 57 set_config('logguests', 1, 'logstore_standard'); 58 $manager = get_log_manager(true); 59 $stores = $manager->get_readers(); 60 $this->store = $stores['logstore_standard']; 61 } 62 63 /** 64 * Return the last log entry from standardlog. 65 * 66 * @return \core\event\base|null The last log event or null if none found. 67 */ 68 public function get_last_log_entry(): ?\core\event\base { 69 70 $select = "component = :component"; 71 $params = ['component' => 'core_xapi']; 72 $records = $this->store->get_events_select($select, $params, 'timecreated DESC', 0, 1); 73 74 if (empty($records)) { 75 return null; 76 } 77 return array_pop($records); 78 } 79 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body