From dc0464801df9898369a85e1d87e6bfede64dcc88 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 13 Jun 2014 16:19:16 +0800 Subject: [PATCH] MDL-1626 mod_forum: Add behat tests for existing functionality --- .../tests/behat/forum_subscriptions.feature | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 mod/forum/tests/behat/forum_subscriptions.feature diff --git a/mod/forum/tests/behat/forum_subscriptions.feature b/mod/forum/tests/behat/forum_subscriptions.feature new file mode 100644 index 00000000000..9120ace1e85 --- /dev/null +++ b/mod/forum/tests/behat/forum_subscriptions.feature @@ -0,0 +1,91 @@ +@mod @mod_forum +Feature: A user can control their own subscription preferences for a forum + In order to receive notifications for things I am interested in + As a user + I need to choose my forum subscriptions + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | student1 | Student | One | student.one@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | student1 | C1 | student | + And I log in as "admin" + And I follow "Course 1" + And I turn editing mode on + + Scenario: A disallowed subscription forum cannot be subscribed to + Given 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 | + | Subscription mode | Subscription disabled | + And I add a new discussion to "Test forum name" forum with: + | Subject | Test post subject | + | Message | Test post message | + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test forum name" + Then I should not see "Subscribe to this forum" + And I should not see "Unsubscribe from this forum" + + Scenario: A forced subscription forum cannot be subscribed to + Given 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 | + | Subscription mode | Forced subscription | + And I add a new discussion to "Test forum name" forum with: + | Subject | Test post subject | + | Message | Test post message | + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test forum name" + Then I should not see "Subscribe to this forum" + And I should not see "Unsubscribe from this forum" + + Scenario: An optional forum can be subscribed to + Given 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 | + | Subscription mode | Optional subscription | + And I add a new discussion to "Test forum name" forum with: + | Subject | Test post subject | + | Message | Test post message | + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test forum name" + Then I should see "Subscribe to this forum" + And I should not see "Unsubscribe from this forum" + And I follow "Subscribe to this forum" + And I follow "Continue" + And I should see "Unsubscribe from this forum" + And I should not see "Subscribe to this forum" + + Scenario: An Automatic forum can be unsubscribed from + Given 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 | + | Subscription mode | Auto subscription | + And I add a new discussion to "Test forum name" forum with: + | Subject | Test post subject | + | Message | Test post message | + And I log out + When I log in as "student1" + And I follow "Course 1" + And I follow "Test forum name" + Then I should see "Unsubscribe from this forum" + And I should not see "Subscribe to this forum" + And I follow "Unsubscribe from this forum" + And I follow "Continue" + And I should see "Subscribe to this forum" + And I should not see "Unsubscribe from this forum"