Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. <?php
  2. use Drupal\DrupalExtension\Context\RawDrupalContext;
  3. use Behat\Behat\Hook\Scope\BeforeScenarioScope;
  4. use Behat\Behat\Context\SnippetAcceptingContext;
  5. use Behat\Behat\Tester\Exception\PendingException;
  6. use Behat\Behat\Hook\Scope\AfterStepScope;
  7. use Behat\Behat\Hook\Scope\BeforeStepScope;
  8. use Behat\Gherkin\Node\PyStringNode;
  9. use Behat\Gherkin\Node\TableNode;
  10. use Behat\Mink\Exception;
  11. use Behat\Mink\Selector;
  12. use Drupal\DrupalExtension\Hook\Scope\AfterUserCreateScope;
  13. /**
  14. * Defines application features from the specific context.
  15. */
  16. class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
  17. private $community_urls;
  18.  
  19.  
  20. /**
  21. * @Given I start a :type community called :title
  22. * @Given I start a :type community called :title with description :description
  23. *
  24. * Type can be public, private, or invite.
  25. *
  26. And I am at "user"
  27. And I click "Start a Community"
  28. Then I fill in "Behat Community" for "title"
  29. And I fill in "This is my test community" for "Body"
  30. # Who can find and access this community and its content? Members Only
  31. And I select "1" from "group_access[und]"
  32. # Is moderator approval required to join this community? No, anyone can join.
  33. And I select "1" from "group_subscribe[und]"
  34. And I press "Save Community"
  35. Then I should see "Behat Community"
  36. And I should see "This is my test community"
  37. */
  38. public function iStartACommunityCalled($type, $title, $body = "") {
  39. // Visit MyEngage, Click Start a community
  40. $this->getSession()->visit('user');
  41. $this->getSession()->getPage()->clickLink('Start a Community');
  42. // Fill out the fields for community.
  43. $this->getSession()->getPage()->fillField("title", $title);
  44. $this->getSession()->getPage()->fillField("Body", $body);
  45. if ($type == 'public') {
  46. $group_access = 0;
  47. $group_subscribe = 1;
  48. }
  49. elseif ($type == 'invite') {
  50. $group_access = 0;
  51. $group_subscribe = 0;
  52. }
  53. elseif ($type == 'private') {
  54. $group_access = 1;
  55. $group_subscribe = 0;
  56. }
  57. else {
  58. throw new \Exception('Group type must be "open membership", "closed membership", or "private"');
  59. }
  60. $this->getSession()->getPage()->selectFieldOption('group_access[und]', $group_access);
  61. if ($group_access != 1) {
  62. $this->getSession()->getPage()->selectFieldOption('group_subscribe[und]', $group_subscribe);
  63. }
  64. // Click the Save button.
  65. $this->getSession()->getPage()->pressButton("Save Community");
  66. // Save the Community URL for later.
  67. $this->community_urls[$title] = $this->getSession()->getCurrentUrl();
  68. // Make sure the page contains the community title and the settings button.
  69. $this->assertSession()->pageTextContains($title);
  70. $this->assertSession()->pageTextContains('Community Settings');
  71. }
  72. /**
  73. * @When I visit the community :title
  74. */
  75. public function iVisitTheCommunityUrl($title)
  76. {
  77. $this->getSession()->visit($this->community_urls[$title]);
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement