mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-44620 behat: Automate MDLQA-7
- MDLQA-7: By default, a new course contains a Latest News block which displays a specific number of recent discussions from the news forum
This commit is contained in:
parent
d46979ec3a
commit
ee9f6db7a2
45
blocks/news_items/tests/behat/display_news.feature
Normal file
45
blocks/news_items/tests/behat/display_news.feature
Normal file
@ -0,0 +1,45 @@
|
||||
@block @block_news_items
|
||||
Feature: Latest news block displays the course latest news
|
||||
In order to be aware of the course news
|
||||
As a user
|
||||
I need to see the latest news in the main course page
|
||||
|
||||
@javascript
|
||||
Scenario: Latest course news are displayed and can be configured
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And I log in as "admin"
|
||||
And I create a course with:
|
||||
| Course full name | Course 1 |
|
||||
| Course short name | C1 |
|
||||
| News items to show | 5 |
|
||||
And I enrol "Teacher 1" user as "Teacher"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
When I add a new topic to "News forum" forum with:
|
||||
| Subject | Discussion One |
|
||||
| Message | Not important |
|
||||
And I add a new topic to "News forum" forum with:
|
||||
| Subject | Discussion Two |
|
||||
| Message | Not important |
|
||||
And I add a new topic to "News forum" forum with:
|
||||
| Subject | Discussion Three |
|
||||
| Message | Not important |
|
||||
And I follow "Course 1"
|
||||
Then I should see "Discussion One" in the "Latest news" "block"
|
||||
And I should see "Discussion Two" in the "Latest news" "block"
|
||||
And I should see "Discussion Three" in the "Latest news" "block"
|
||||
And I follow "Edit settings"
|
||||
And I set the following fields to these values:
|
||||
| News items to show | 2 |
|
||||
And I press "Save changes"
|
||||
And I should not see "Discussion One" in the "Latest news" "block"
|
||||
And I should see "Discussion Two" in the "Latest news" "block"
|
||||
And I should see "Discussion Three" in the "Latest news" "block"
|
||||
And I follow "Edit settings"
|
||||
And I set the following fields to these values:
|
||||
| News items to show | 0 |
|
||||
And I press "Save changes"
|
||||
And "Latest news" "block" should not exist
|
@ -39,6 +39,17 @@ use Behat\Behat\Context\Step\Given as Given,
|
||||
*/
|
||||
class behat_mod_forum extends behat_base {
|
||||
|
||||
/**
|
||||
* Adds a topic to the forum specified by it's name. Useful for the News forum and blog-style forums.
|
||||
*
|
||||
* @Given /^I add a new topic to "(?P<forum_name_string>(?:[^"]|\\")*)" forum with:$/
|
||||
* @param string $forumname
|
||||
* @param TableNode $table
|
||||
*/
|
||||
public function i_add_a_new_topic_to_forum_with($forumname, TableNode $table) {
|
||||
return $this->add_new_discussion($forumname, $table, get_string('addanewtopic', 'forum'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
@ -47,15 +58,7 @@ class behat_mod_forum extends behat_base {
|
||||
* @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 "' . get_string('addanewdiscussion', 'forum') . '"'),
|
||||
new Given('I set the following fields to these values:', $table),
|
||||
new Given('I press "' . get_string('posttoforum', 'forum') . '"'),
|
||||
new Given('I wait to be redirected')
|
||||
);
|
||||
return $this->add_new_discussion($forumname, $table, get_string('addanewdiscussion', 'forum'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,4 +81,29 @@ class behat_mod_forum extends behat_base {
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the steps list to add a new discussion to a forum.
|
||||
*
|
||||
* Abstracts add a new topic and add a new discussion, as depending
|
||||
* on the forum type the button string changes.
|
||||
*
|
||||
* @param string $forumname
|
||||
* @param TableNode $table
|
||||
* @param string $buttonstr
|
||||
* @return Given[]
|
||||
*/
|
||||
protected function add_new_discussion($forumname, TableNode $table, $buttonstr) {
|
||||
|
||||
// Escaping $forumname as it has been stripped automatically by the transformer.
|
||||
return array(
|
||||
new Given('I follow "' . $this->escape($forumname) . '"'),
|
||||
new Given('I press "' . $buttonstr . '"'),
|
||||
new Given('I set the following fields to these values:', $table),
|
||||
new Given('I press "' . get_string('posttoforum', 'forum') . '"'),
|
||||
new Given('I wait to be redirected')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user