Skip to content

Commit

Permalink
Add Behat test for accept/deny invitations to social group - refs #8095
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Feb 18, 2016
1 parent a8c216d commit aec6d4f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
21 changes: 17 additions & 4 deletions tests/features/bootstrap/FeatureContext.php
Expand Up @@ -3,6 +3,7 @@
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Context\Step,
Behat\Behat\Context\Step\Given,
Behat\Behat\Exception\PendingException,
Behat\Behat\Event\SuiteEvent;
Expand Down Expand Up @@ -204,13 +205,13 @@ public function iAmLoggedAs($username)
}

/**
* @Given /^I have a friend$/
* @Given /^I have a friend named "([^"]*)" with id "([^"]*)"$/
*/
public function iHaveAFriend()
public function iHaveAFriend($friendUsername, $friendId)
{
$adminId = 1;
$friendId = 11;
$friendUsername = 'fbaggins';
$friendId = $friendId;
$friendUsername = $friendUsername;

$sendInvitationURL = '/main/inc/ajax/message.ajax.php?' . http_build_query([
'a' => 'send_invitation',
Expand Down Expand Up @@ -261,4 +262,16 @@ public function iAmNotLogged()
new Given('I am on homepage')
];
}

/**
* @When /^I invite to a friend with id "([^"]*)" to a social group with id "([^"]*)"$/
*/
public function iInviteAFrienToASocialGroup($friendId, $groupId)
{
return [
new Step\Given('I am on "/main/social/group_invitation.php?id=' . $groupId . '"'),
new Step\When('I fill in "invitation[]" with "' . $friendId . '"'),
new Step\When('I press "submit"')
];
}
}
21 changes: 17 additions & 4 deletions tests/features/socialGroup.feature
Expand Up @@ -14,8 +14,21 @@ Feature: Social Group

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"
And I have a friend named "fbaggins" with id "11"
When I invite to a friend with id "11" to a social group with id "1"
Then I should see "Invitation sent"

Scenario: Accept an invitation to social group
Given I am logged as "fbaggins"
And I am on "/main/social/invitations.php"
When I follow "accept-invitation-1"
Then I should see "User is subscribed to this group"

Scenario: Deny an invitation to social group
Given I am a platform administrator
And I have a friend named "sgamgee" with id "13"
And I invite to a friend with id "13" to a social group with id "1"
When I am logged as "sgamgee"
And I am on "/main/social/invitations.php"
And I follow "deny-invitation-1"
Then I should see "Group invitation was denied"

1 comment on commit aec6d4f

@jmontoyaa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm commenting this part of code in order to avoid hard coded values like:

"I have a friend named "fbaggins" with id "11""

Please sign in to comment.