Merge branch 'MDL-38437_master' of git://github.com/dmonllao/moodle

This commit is contained in:
Eloy Lafuente (stronk7)
2013-04-02 01:03:26 +02:00
3 changed files with 152 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
@mod_forum
Feature: Add forum activities and discussions
In order to discuss topics with other users
As a moodle teacher
I need to add forum activities to moodle courses
@javascript
Scenario: Add a forum and a discussion
Given the following "users" exists:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@asd.com |
And the following "courses" exists:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exists:
| user | course | role |
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "forum" to section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
When I add a new discussion to "Test forum name" forum with:
| Subject | Forum post 1 |
| Message | This is the body |
And I wait "6" seconds
Then I should see "Test forum name"
+61
View File
@@ -0,0 +1,61 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Steps definitions related with the forum activity.
*
* @package mod_forum
* @category test
* @copyright 2013 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php.
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
use Behat\Behat\Context\Step\Given as Given,
Behat\Gherkin\Node\TableNode as TableNode;
/**
* Forum-related steps definitions.
*
* @package mod_forum
* @category test
* @copyright 2013 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_mod_forum extends behat_base {
/**
* 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.
*
* @Given /^I add a new discussion to "(?P<forum_name_string>(?:[^"]|\\")*)" forum with:$/
* @param string $forumname
* @param TableNode $table
*/
public function i_add_a_forum_discussion_to_forum_with($forumname, TableNode $table) {
// Escaping $forumname as it has been stripped automatically by the transformer.
return array(
new Given('I follow "' . $this->escape($forumname) . '"'),
new Given('I press "Add a new discussion topic"'),
new Given('I fill the moodle form with:', $table),
new Given('I press "Post to forum"'),
new Given('I wait "5" seconds')
);
}
}
@@ -0,0 +1,62 @@
@mod_forum
Feature: Students can edit or delete their forum posts within a set time limit
In order to refine forum posts
As a moodle user
I need to edit or delete my forum posts within a certain period of time after posting
Background:
Given the following "users" exists:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@asd.com |
And the following "courses" exists:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following "course enrolments" exists:
| user | course | role |
| student1 | C1 | student |
And I log in as "admin"
And I expand "Site administration" node
And I expand "Security" node
And I follow "Site policies"
And I select "1 minutes" from "Maximum time to edit posts"
And I press "Save changes"
And I am on homepage
And I follow "Course 1"
And I turn editing mode on
And I add a "forum" to section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
And I log out
And I follow "Course 1"
And I log in as "student1"
And I add a new discussion to "Test forum name" forum with:
| Subject | Forum post subject |
| Message | This is the body |
And I wait "6" seconds
@javascript
Scenario: Edit forum post
When I follow "Forum post subject"
And I follow "Edit"
And I fill the moodle form with:
| Subject | Edited post subject |
| Message | Edited post body |
And I press "Save changes"
And I wait "6" seconds
Then I should see "Edited post subject"
And I should see "Edited post body"
@javascript
Scenario: Delete forum post
When I follow "Forum post subject"
And I follow "Delete"
And I press "Continue"
Then I should not see "Forum post subject"
@javascript
Scenario: Time limit expires
When I wait "70" seconds
And I follow "Forum post subject"
Then I should not see "Edit"
And I should not see "Delete"