[ Index ] |
PHP Cross Reference of Unnamed Project |
[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 * Steps definitions related with the forum activity. 19 * 20 * @package mod_forum 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\Gherkin\Node\TableNode as TableNode; 31 /** 32 * Forum-related steps definitions. 33 * 34 * @package mod_forum 35 * @category test 36 * @copyright 2013 David Monllaó 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class behat_mod_forum extends behat_base { 40 41 /** 42 * Adds a topic to the forum specified by it's name. Useful for the Announcements and blog-style forums. 43 * 44 * @Given /^I add a new topic to "(?P<forum_name_string>(?:[^"]|\\")*)" forum with:$/ 45 * @param string $forumname 46 * @param TableNode $table 47 */ 48 public function i_add_a_new_topic_to_forum_with($forumname, TableNode $table) { 49 $this->add_new_discussion($forumname, $table, get_string('addanewtopic', 'forum')); 50 } 51 52 /** 53 * Adds a discussion to the forum specified by it's name with the provided table data (usually Subject and Message). The step begins from the forum's course page. 54 * 55 * @Given /^I add a new discussion to "(?P<forum_name_string>(?:[^"]|\\")*)" forum with:$/ 56 * @param string $forumname 57 * @param TableNode $table 58 */ 59 public function i_add_a_forum_discussion_to_forum_with($forumname, TableNode $table) { 60 $this->add_new_discussion($forumname, $table, get_string('addanewdiscussion', 'forum')); 61 } 62 63 /** 64 * Adds a reply to the specified post of the specified forum. The step begins from the forum's page or from the forum's course page. 65 * 66 * @Given /^I reply "(?P<post_subject_string>(?:[^"]|\\")*)" post from "(?P<forum_name_string>(?:[^"]|\\")*)" forum with:$/ 67 * @param string $postname The subject of the post 68 * @param string $forumname The forum name 69 * @param TableNode $table 70 */ 71 public function i_reply_post_from_forum_with($postsubject, $forumname, TableNode $table) { 72 73 // Navigate to forum. 74 $this->execute('behat_general::click_link', $this->escape($forumname)); 75 $this->execute('behat_general::click_link', $this->escape($postsubject)); 76 $this->execute('behat_general::click_link', get_string('reply', 'forum')); 77 78 // Fill form and post. 79 $this->execute('behat_forms::i_set_the_following_fields_to_these_values', $table); 80 81 $this->execute('behat_forms::press_button', get_string('posttoforum', 'forum')); 82 $this->execute('behat_general::i_wait_to_be_redirected'); 83 } 84 85 /** 86 * Returns the steps list to add a new discussion to a forum. 87 * 88 * Abstracts add a new topic and add a new discussion, as depending 89 * on the forum type the button string changes. 90 * 91 * @param string $forumname 92 * @param TableNode $table 93 * @param string $buttonstr 94 */ 95 protected function add_new_discussion($forumname, TableNode $table, $buttonstr) { 96 97 // Navigate to forum. 98 $this->execute('behat_general::click_link', $this->escape($forumname)); 99 $this->execute('behat_forms::press_button', $buttonstr); 100 101 // Fill form and post. 102 $this->execute('behat_forms::i_set_the_following_fields_to_these_values', $table); 103 $this->execute('behat_forms::press_button', get_string('posttoforum', 'forum')); 104 $this->execute('behat_general::i_wait_to_be_redirected'); 105 } 106 107 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |