Advertisement
Guest User

Untitled

a guest
May 27th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'RandomUtil.class.php';
  4. use Drupal\DrupalExtension\Context\RawDrupalContext;
  5. use Behat\Behat\Context\SnippetAcceptingContext;
  6. use Behat\Gherkin\Node\PyStringNode;
  7. use Behat\Gherkin\Node\TableNode;
  8. use Behat\MinkExtension\Context\MinkRedirectContext;
  9.  
  10. /**
  11. * Defines application features from the specific context.
  12. */
  13. class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
  14. private $email_address;
  15.  
  16. /**
  17. * Initializes context.
  18. *
  19. * Every scenario gets its own context instance.
  20. * You can also pass arbitrary arguments to the
  21. * context constructor through behat.yml.
  22. */
  23. public function __construct() {
  24. }
  25. /**
  26. * @When I enter a random email address into the form
  27. */
  28. public function enterEmail() {
  29. $random_email_address = RandomUtil::getRandomEmail();
  30. $this->email_address = $random_email_address;
  31. }
  32.  
  33. /**
  34. * @Then I should see previously entered email on the thank you page.
  35. */
  36. public function checkForEmail() {
  37. $saved_email = $this->email_address;
  38. $page = $this->getSession()->getPage();
  39. $email_element = $page->find('css', '.email');
  40. $value = $email_element->getText();
  41.  
  42. if ($value !== $saved_email) {
  43. throw new Exception("Email does not match expected value");
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement