From aabd8a29efbc8cc7864ac3b7ede4173c0fd591e0 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 16 Feb 2016 17:11:48 -0500 Subject: [PATCH] Add Behat tests for social group - refs #8089 --- tests/features/bootstrap/FeatureContext.php | 43 +++++++++++++++++++++ tests/features/socialGroup.feature | 21 ++++++++++ 2 files changed, 64 insertions(+) create mode 100644 tests/features/socialGroup.feature diff --git a/tests/features/bootstrap/FeatureContext.php b/tests/features/bootstrap/FeatureContext.php index e9f4ad72ae..6133fb5c57 100644 --- a/tests/features/bootstrap/FeatureContext.php +++ b/tests/features/bootstrap/FeatureContext.php @@ -188,4 +188,47 @@ class FeatureContext extends MinkContext new Given('the "language" field should contain "' . $argument . '"') ); } + + /** + * @Given /^I am logged as "([^"]*)"$/ + */ + public function iAmLoggedAs($username) + { + return [ + new Given('I am on "/index.php?logout=logout"'), + new Given('I am on homepage'), + new Given('I fill in "login" with "' . $username . '"'), + new Given('I fill in "password" with "' . $username . '"'), + new Given('I press "submitAuth"') + ]; + } + + /** + * @Given /^I have a friend$/ + */ + public function iHaveAFriend() + { + $adminId = 1; + $friendId = 11; + $friendUsername = 'fbaggins'; + + $sendInvitationURL = '/main/inc/ajax/message.ajax.php?' . http_build_query([ + 'a' => 'send_invitation', + 'user_id' => $friendId, + 'content' => 'Add me' + ]); + $acceptInvitationURL = '/main/inc/ajax/social.ajax.php?' . http_build_query([ + 'a' => 'add_friend', + 'friend_id' => $adminId, + 'is_my_friend' => 'friend' + ]); + + return array( + new Given('I am a platform administrator'), + new Given('I am on "' . $sendInvitationURL . '"'), + new Given('I am logged as "' . $friendUsername . '"'), + new Given('I am on "' . $acceptInvitationURL . '"'), + new Given('I am a platform administrator') + ); + } } diff --git a/tests/features/socialGroup.feature b/tests/features/socialGroup.feature new file mode 100644 index 0000000000..01f4caf25d --- /dev/null +++ b/tests/features/socialGroup.feature @@ -0,0 +1,21 @@ +Feature: Social Group + In order to use the Social Network + As an administrator + I need to be able to create a social group, invite users and post a message + + Scenario: Create a social group + Given I am a platform administrator + And I am on "/main/social/group_add.php" + When I fill in the following: + | name | Behat Test Group | + | description | This is a group created by Behat | + And I press "submit" + Then I should see "Group added" + + Scenario: Invite a friend to group + Given I am a platform administrator + And I have a friend + And I am on "/main/social/group_invitation.php?id=1" + When I fill in "invitation[]" with "11" + And I press "submit" + Then I should see "Invitation sent"