Skip to content

Commit

Permalink
Merge pull request #467 from jhedstrom/466-configure-ajax-timeout
Browse files Browse the repository at this point in the history
Allows AJAX timeout to be overridden.
  • Loading branch information
jhedstrom authored Feb 26, 2018
2 parents 3306359 + e625ede commit 4753309
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 9 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added
* [#467](https://github.com/jhedstrom/drupalextension/pull/467): Allows
AJAX timeout to be overridden via an `ajax_timeout` parameter in `behat.yml`.
In order to utilize this parameter, `Drupal\MinkExtension` should be specified
in the `extensions` portion of `behat.yml` rather than `Behat\MinkExtension`.

[Unreleased]: https://github.com/jhedstrom/drupalextension/compare/v4.0.0alpha2...HEAD
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ the [Full documentation](https://behat-drupal-extension.readthedocs.org)

## Release notes

See [CHANGELOG](CHANGELOG.md).

### Backwards incompatible changes

Starting with 3.3.0 Behat Drupal Extension depends on Behat 3.2.0 which
Expand Down
2 changes: 1 addition & 1 deletion behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ default:
filters:
tags: "@blackbox"
extensions:
Behat\MinkExtension:
Drupal\MinkExtension:
goutte: ~
zombie: ~
base_url: http://127.0.0.1:8888/blackbox
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"psr-0": {
"Drupal\\Drupal": "src/",
"Drupal\\Exception": "src/",
"Drupal\\DrupalExtension": "src/"
"Drupal\\DrupalExtension": "src/",
"Drupal\\MinkExtension": "src/"
}
},
"extra": {
Expand Down
2 changes: 1 addition & 1 deletion doc/_static/snippets/behat-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default:
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
Behat\MinkExtension:
Drupal\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://seven.l
Expand Down
2 changes: 1 addition & 1 deletion doc/_static/snippets/behat-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default:
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
Drupal\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://seven.l
Expand Down
2 changes: 1 addition & 1 deletion doc/_static/snippets/behat-auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default:
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
Drupal\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://seven.l
Expand Down
2 changes: 1 addition & 1 deletion doc/_static/snippets/behat-bb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default:
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
Drupal\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://seven.l
Expand Down
2 changes: 1 addition & 1 deletion doc/_static/snippets/behat-drush.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default:
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
Drupal\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://seven.l
Expand Down
2 changes: 1 addition & 1 deletion doc/_static/snippets/behat-sub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default:
paths:
- "./path_to_module/features"
extensions:
Behat\MinkExtension:
Drupal\MinkExtension:
goutte: ~
selenium2: ~
base_url: http://seven.l
Expand Down
19 changes: 19 additions & 0 deletions spec/Drupal/MinkExtension/ServiceContainer/MinkExtensionSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace spec\Drupal\MinkExtension\ServiceContainer;

use Behat\Testwork\ServiceContainer\Extension;
use PhpSpec\ObjectBehavior;

class MinkExtensionSpec extends ObjectBehavior
{
function it_is_a_testwork_extension()
{
$this->shouldHaveType(Extension::class);
}

function it_is_named_mink()
{
$this->getConfigKey()->shouldReturn('mink');
}
}
2 changes: 1 addition & 1 deletion src/Drupal/DrupalExtension/Context/MinkContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function isAjaxing(instance) {
);
}());
JS;
$result = $this->getSession()->wait(5000, $condition);
$result = $this->getSession()->wait(1000 * $this->getMinkParameter('ajax_timeout'), $condition);
if (!$result) {
throw new \RuntimeException('Unable to complete AJAX request.');
}
Expand Down
33 changes: 33 additions & 0 deletions src/Drupal/MinkExtension/ServiceContainer/MinkExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Drupal\MinkExtension\ServiceContainer;

use Behat\MinkExtension\ServiceContainer\MinkExtension as BaseMinkExtension;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

class MinkExtension extends BaseMinkExtension
{

/**
* Default wait time for AJAX to finish (in seconds).
*
* @var int
*/
const AJAX_TIMEOUT = 5;

/**
* {@inheritdoc}
*/
public function configure(ArrayNodeDefinition $builder)
{
parent::configure($builder);

// Add extended options.
$builder->
children()->
scalarNode('ajax_timeout')->
defaultValue(static::AJAX_TIMEOUT)->
info(sprintf('Change the maximum time to wait for AJAX calls to complete. Defaults to %s seconds.', static::AJAX_TIMEOUT))->
end();
}
}

0 comments on commit 4753309

Please sign in to comment.