[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
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 * Completion steps definitions. 19 * 20 * @package core_completion 21 * @category test 22 * @copyright 2013 David Monllaó 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. 27 28 require_once (__DIR__ . '/../../../lib/behat/behat_base.php'); 29 30 use Behat\Behat\Context\Step\Given as Given, 31 Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException; 32 33 /** 34 * Steps definitions to deal with course and activities completion. 35 * 36 * @package core_completion 37 * @category test 38 * @copyright 2013 David Monllaó 39 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 40 */ 41 class behat_completion extends behat_base { 42 43 /** 44 * Checks that the specified user has completed the specified activity of the current course. 45 * 46 * @Then /^"(?P<user_fullname_string>(?:[^"]|\\")*)" user has completed "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/ 47 * @param string $userfullname 48 * @param string $activityname 49 */ 50 public function user_has_completed_activity($userfullname, $activityname) { 51 52 // Will throw an exception if the element can not be hovered. 53 $titleliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($userfullname . ", " . $activityname . ": Completed"); 54 $xpath = "//table[@id='completion-progress']" . 55 "/descendant::img[contains(@title, $titleliteral)]"; 56 57 return array( 58 new Given('I go to the current course activity completion report'), 59 new Given('I hover "' . $this->escape($xpath) . '" "xpath_element"') 60 ); 61 } 62 63 /** 64 * Checks that the specified user has not completed the specified activity of the current course. 65 * 66 * @Then /^"(?P<user_fullname_string>(?:[^"]|\\")*)" user has not completed "(?P<activity_name_string>(?:[^"]|\\")*)" activity$/ 67 * @param string $userfullname 68 * @param string $activityname 69 */ 70 public function user_has_not_completed_activity($userfullname, $activityname) { 71 72 // Will throw an exception if the element can not be hovered. 73 $titleliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($userfullname . ", " . $activityname . ": Not completed"); 74 $xpath = "//table[@id='completion-progress']" . 75 "/descendant::img[contains(@title, $titleliteral)]"; 76 return array( 77 new Given('I go to the current course activity completion report'), 78 new Given('I hover "' . $this->escape($xpath) . '" "xpath_element"') 79 ); 80 81 return $steps; 82 } 83 84 /** 85 * Goes to the current course activity completion report. 86 * 87 * @Given /^I go to the current course activity completion report$/ 88 */ 89 public function go_to_the_current_course_activity_completion_report() { 90 91 $steps = array(); 92 93 // Expand reports node if we can't see the link. 94 try { 95 $this->find('xpath', "//div[@id='settingsnav']" . 96 "/descendant::li" . 97 "/descendant::li[not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed '))]" . 98 "/descendant::p[contains(., '" . get_string('pluginname', 'report_progress') . "')]"); 99 } catch (ElementNotFoundException $e) { 100 $steps[] = new Given('I expand "' . get_string('reports') . '" node'); 101 } 102 103 $steps[] = new Given('I follow "' . get_string('pluginname', 'report_progress') . '"'); 104 105 return $steps; 106 } 107 108 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |