Commit 3dd99b01 authored by lsolesen's avatar lsolesen

Tests updated to Behat 3

parent e706fc4e
......@@ -53,7 +53,7 @@ install:
# Setting Behat environment
- DISTRO=`echo $TRAVIS_BUILD_DIR | sed -e "s/\/[^\/]*$//"`
- export BEHAT_PARAMS="extensions[Drupal\\DrupalExtension\\Extension][drupal][drupal_root]=$DISTRO/drupal"
- export BEHAT_PARAMS="{\"extensions\":{\"Drupal\\\DrupalExtension\":{\"drupal\":{\"drupal_root\":\"$DISTRO/drupal\"}}}}"
# Build Codebase
- mkdir private_files
......
......@@ -7,7 +7,7 @@ Setup
1. Install Composer
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
2. Install Behat and dependencies via Composer
php composer.phar install
......@@ -15,8 +15,7 @@ Setup
3. Copy behat.yml.example to behat.yml and modify
cp behat.template.yml behat.yml
4. Run Behat and examine test results!
bin/behat
bin/behat
default:
paths:
features: 'features'
suites:
default:
paths:
features: 'features'
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Behat\MinkExtension\Extension:
Behat\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://${drupal.uri}
files_path: ../../
Drupal\DrupalExtension\Extension:
Drupal\DrupalExtension:
blackbox: ~
drush:
root: ${drush.root}
......
default:
paths:
features: 'features'
suites:
default:
paths:
features: 'features'
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Behat\MinkExtension\Extension:
Behat\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://127.0.0.1:8888
files_path: ../../
Drupal\DrupalExtension\Extension:
Drupal\DrupalExtension:
blackbox: ~
drush:
alias: self
......
{
"require": {
"drupal/drupal-extension": "1.0.0",
"symfony/css-selector": "2.4.2",
"symfony/finder": "2.4.2",
"symfony/yaml": "2.4.2",
"symfony/translation": "2.4.2",
"symfony/event-dispatcher": "2.4.2",
"symfony/filesystem": "2.4.2",
"symfony/config": "2.4.2",
"symfony/console": "2.4.2",
"symfony/process": "2.4.2",
"symfony/dom-crawler": "2.4.2",
"symfony/browser-kit": "2.4.2"
"drupal/drupal-extension": "~3.0"
},
"config": {
"bin-dir": "bin/"
......
<?php
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Context\ClosuredContextInterface,
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Context\BehatContext,
Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
use Drupal\DrupalExtension\Context\DrupalContext;
use Symfony\Component\Process\Process;
use Behat\Behat\Context\Step\Given;
use Behat\Behat\Context\Step\When;
use Behat\Behat\Context\Step\Then;
use Behat\Behat\Event\ScenarioEvent;
use Behat\Behat\Event\StepEvent;
use Behat\Mink\Exception\ElementNotFoundException;
Behat\Behat\Context\TranslatedContextInterface,
Behat\Behat\Event\ScenarioEvent,
Behat\Behat\Exception\PendingException;
use Drupal\Component\Utility\Random;
require 'vendor/autoload.php';
......@@ -28,14 +23,14 @@ require 'vendor/autoload.php';
/**
* Features context.
*/
class FeatureContext extends DrupalContext {
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
/**
* Initializes context.
* Every scenario gets its own context object.
*
* @param array $parameters context parameters (set them up through behat.yml)
*/
public function __construct(array $parameters) {
public function __construct() {
// Initialize your context here
}
......@@ -66,7 +61,7 @@ class FeatureContext extends DrupalContext {
foreach ($table as $key => $value) {
$link = $table[$key]['links'];
$result = $page->findLink($link);
if(empty($result)) {
if (empty($result)) {
throw new Exception("The link '" . $link . "' was not found");
}
}
......@@ -81,7 +76,7 @@ class FeatureContext extends DrupalContext {
foreach ($table as $key => $value) {
$link = $table[$key]['links'];
$result = $page->findLink($link);
if(!empty($result)) {
if (!empty($result)) {
throw new Exception("The link '" . $link . "' was found");
}
}
......@@ -112,17 +107,6 @@ class FeatureContext extends DrupalContext {
}
}
/**
* @Given /^I fill in "([^"]*)" with random text$/
*/
public function iFillInWithRandomText($label) {
// A @Tranform would be more elegant.
$randomString = $this->randomString(10);
$step = "I fill in \"$label\" with \"$randomString\"";
return new Then($step);
}
/**
* Helper function to fetch user details stored in behat.local.yml.
*
......
......@@ -11,18 +11,13 @@ Feature: Login Commerce Kickstart
| Forgot your password? |
| Create an account |
Scenario Outline: Username validation: Invalid username
Scenario: Username validation: Invalid username
When I go to "/user/login"
And I fill in "Username" with "<name>"
And I fill in "Password" with random text
And I fill in "Username" with "randomname"
And I fill in "Password" with "invalidpassword"
And I press "Log in"
Then I should see "Sorry, unrecognized username or password."
And the field "Username" should be outlined in red
Examples:
| name |
| randomname |
| 123453 |
| mail@mail.com |
Scenario: User should be able to login and see the user profile
When I go to "/user/login"
......@@ -57,4 +52,3 @@ Feature: Login Commerce Kickstart
| Update email/password |
| Connections |
| Order history |
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment