See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
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 calendar-related steps definitions. 19 * 20 * @package core_calendar 21 * @category test 22 * @copyright 2013 Mark Nelson <markn@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 // NOTE: no MOODLE_INTERNAL used, this file may be required by behat before including /config.php. 27 require_once (__DIR__ . '/../../../lib/behat/behat_base.php'); 28 29 use Behat\Gherkin\Node\TableNode as TableNode; 30 31 /** 32 * Contains functions used by behat to test functionality. 33 * 34 * @package core_calendar 35 * @category test 36 * @copyright 2013 Mark Nelson <markn@moodle.com> 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class behat_calendar extends behat_base { 40 41 /** 42 * Return the list of partial named selectors. 43 * 44 * @return array 45 */ 46 public static function get_partial_named_selectors(): array { 47 return [ 48 new behat_component_named_selector('mini calendar block', [".//*[@data-block='calendar_month']"]), 49 new behat_component_named_selector('full calendar page', [".//*[@id='page-calendar-view']"]), 50 new behat_component_named_selector('calendar day', [".//*[@data-region='day'][@data-day=%locator%]"]), 51 ]; 52 } 53 54 /** 55 * Create event when starting on the front page. 56 * 57 * @Given /^I create a calendar event with form data:$/ 58 * @param TableNode $data 59 */ 60 public function i_create_a_calendar_event_with_form_data($data) { 61 // Go to current month page. 62 $this->execute("behat_general::click_link", get_string('fullcalendar', 'calendar')); 63 64 // Create event. 65 $this->i_create_a_calendar_event($data); 66 } 67 68 /** 69 * Create event. 70 * 71 * @Given /^I create a calendar event:$/ 72 * @param TableNode $data 73 */ 74 public function i_create_a_calendar_event($data) { 75 // Get the event name. 76 $eventname = $data->getRow(1); 77 $eventname = $eventname[1]; 78 79 $this->execute("behat_general::wait_until_the_page_is_ready"); 80 81 if ($this->running_javascript()) { 82 // Click to create new event. 83 $this->execute("behat_general::i_click_on", array(get_string('newevent', 'calendar'), "button")); 84 85 // Set form fields. 86 $this->execute("behat_forms::i_set_the_following_fields_to_these_values", $data); 87 88 // Save event. 89 $this->execute("behat_forms::press_button", get_string('save')); 90 } 91 } 92 93 /** 94 * Hover over a specific day in the mini-calendar. 95 * 96 * @Given /^I hover over day "(?P<dayofmonth>\d+)" of this month in the mini-calendar block$/ 97 * @param int $day The day of the current month 98 */ 99 public function i_hover_over_day_of_this_month_in_mini_calendar_block(int $day): void { 100 $this->execute("behat_general::i_hover_in_the", 101 [$day, 'core_calendar > calendar day', '', 'core_calendar > mini calendar block']); 102 } 103 104 /** 105 * Hover over a specific day in the full calendar page. 106 * 107 * @Given /^I hover over day "(?P<dayofmonth>\d+)" of this month in the full calendar page$/ 108 * @param int $day The day of the current month 109 */ 110 public function i_hover_over_day_of_this_month_in_full_calendar_page(int $day): void { 111 $this->execute("behat_general::i_hover_in_the", 112 [$day, 'core_calendar > calendar day', '', 'core_calendar > full calendar page']); 113 } 114 115 /** 116 * Hover over today in the mini-calendar. 117 * 118 * @Given /^I hover over today in the mini-calendar block$/ 119 */ 120 public function i_hover_over_today_in_mini_calendar_block(): void { 121 $todaysday = date('j'); 122 $this->i_hover_over_day_of_this_month_in_mini_calendar_block($todaysday); 123 } 124 125 /** 126 * Hover over today in the calendar. 127 * 128 * @Given /^I hover over today in the calendar$/ 129 */ 130 public function i_hover_over_today_in_the_calendar() { 131 $todaysday = date('j'); 132 return $this->i_hover_over_day_of_this_month_in_calendar($todaysday); 133 } 134 135 /** 136 * Navigate to a specific month in the calendar. 137 * 138 * @Given /^I view the calendar for "(?P<month>\d+)" "(?P<year>\d+)"$/ 139 * @param int $month the month selected as a number 140 * @param int $year the four digit year 141 */ 142 public function i_view_the_calendar_for($month, $year) { 143 $this->view_the_calendar('month', 1, $month, $year); 144 } 145 146 /** 147 * Navigate to a specific date in the calendar. 148 * 149 * @Given /^I view the calendar for "(?P<day>\d+)" "(?P<month>\d+)" "(?P<year>\d+)"$/ 150 * @param int $day the day selected as a number 151 * @param int $month the month selected as a number 152 * @param int $year the four digit year 153 */ 154 public function i_view_the_calendar_day_view(int $day, int $month, int $year) { 155 $this->view_the_calendar('day', $day, $month, $year); 156 } 157 158 /** 159 * View the correct calendar view with specific day 160 * 161 * @param string $type type of calendar view: month or day 162 * @param int $day the day selected as a number 163 * @param int $month the month selected as a number 164 * @param int $year the four digit year 165 */ 166 private function view_the_calendar(string $type, int $day, int $month, int $year) { 167 $time = make_timestamp($year, $month, $day); 168 $this->execute('behat_general::i_visit', ['/calendar/view.php?view=' . $type . '&course=1&time=' . $time]); 169 } 170 171 /** 172 * Navigate to site calendar. 173 * 174 * @Given /^I am viewing site calendar$/ 175 * @throws coding_exception 176 * @return void 177 */ 178 public function i_am_viewing_site_calendar() { 179 $url = new moodle_url('/calendar/view.php', ['view' => 'month']); 180 $this->execute('behat_general::i_visit', [$url]); 181 } 182 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body