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 * Behat competency report definitions. 19 * 20 * @package report_competency 21 * @category test 22 * @copyright 2022 Noel De Martin 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 require_once (__DIR__ . '/../../../../lib/behat/behat_base.php'); 27 28 /** 29 * Competency report definitions. 30 * 31 * @package report_competency 32 * @category test 33 * @copyright 2022 Noel De Martin 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class behat_report_competency extends behat_base { 37 38 /** 39 * Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'. 40 * 41 * Recognised page names are: 42 * | pagetype | name meaning | description | 43 * | Breakdown | Course name | The course competencies breakdown page | 44 * 45 * @param string $page identifies which type of page this is, e.g. 'Breakdown'. 46 * @param string $identifier identifies the particular page, e.g. 'C1'. 47 * @return moodle_url the corresponding URL. 48 * @throws Exception with a meaningful error message if the specified page cannot be found. 49 */ 50 protected function resolve_page_instance_url(string $page, string $identifier): moodle_url { 51 switch (strtolower($page)) { 52 case 'breakdown': 53 $courseid = $this->get_course_id($identifier); 54 return new moodle_url('/report/competency/index.php', [ 55 'id' => $courseid, 56 ]); 57 default: 58 throw new Exception("Unrecognised page type '{$page}'"); 59 } 60 } 61 62 /** 63 * Return a list of the exact named selectors for the component. 64 * 65 * @return behat_component_named_selector[] 66 */ 67 public static function get_exact_named_selectors(): array { 68 return [ 69 new behat_component_named_selector('breakdown', [ 70 "//*[@data-region='competency-breakdown-report']//table". 71 "//tr[contains(., //a[@data-action='competency-dialogue'][contains(., %locator%)])]", 72 ]), 73 new behat_component_named_selector('breakdown rating', [ 74 "//td[position()=2][contains(., //a[@title='User competency summary'][contains(., %locator%)])]", 75 ]), 76 ]; 77 } 78 79 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body