Change default configuration to use local helper

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2017-04-19 08:05:40 +02:00
parent 59004dc75e
commit eea015c1ba
2 changed files with 8 additions and 29 deletions

View File

@ -40,13 +40,12 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
*
* The Nextcloud server is provided by an instance of NextcloudTestServerHelper;
* its class must be specified when this context is created. By default,
* "NextcloudTestServerDockerHelper" is used, although that can be customized
* "NextcloudTestServerLocalHelper" is used, although that can be customized
* using the "nextcloudTestServerHelper" parameter in "behat.yml". In the same
* way, the parameters to be passed to the helper when it is created can be
* customized using the "nextcloudTestServerHelperParameters" parameter, which
* is an array (without keys) with the value of the parameters in the same order
* as in the constructor of the helper class (by default,
* [ "nextcloud-local-test-acceptance", "selenium-nextcloud-local-test-acceptance" ]).
* as in the constructor of the helper class (by default, [ ]).
*
* Example of custom parameters in "behat.yml":
* default:
@ -54,16 +53,10 @@ use Behat\Behat\Hook\Scope\BeforeScenarioScope;
* default:
* contexts:
* - NextcloudTestServerContext:
* nextcloudTestServerHelper: NextcloudTestServerDockerHelper
* nextcloudTestServerHelper: NextcloudTestServerCustomHelper
* nextcloudTestServerHelperParameters:
* - nextcloud-local-test-acceptance-custom-image
* - selenium-nextcloud-local-test-acceptance-custom-image
*
* Note that using Docker containers as a regular user requires giving access to
* the Docker daemon to that user. Unfortunately, that makes possible for that
* user to get root privileges for the system. Please see the
* NextcloudTestServerDockerHelper documentation for further information on this
* issue.
* - first-parameter-value
* - second-parameter-value
*/
class NextcloudTestServerContext implements Context {
@ -80,8 +73,8 @@ class NextcloudTestServerContext implements Context {
* @param array $nextcloudTestServerHelperParameters the parameters for the
* constructor of the $nextcloudTestServerHelper class.
*/
public function __construct($nextcloudTestServerHelper = "NextcloudTestServerDockerHelper",
$nextcloudTestServerHelperParameters = [ "nextcloud-local-test-acceptance", "selenium-nextcloud-local-test-acceptance" ]) {
public function __construct($nextcloudTestServerHelper = "NextcloudTestServerLocalHelper",
$nextcloudTestServerHelperParameters = [ ]) {
$nextcloudTestServerHelperClass = new ReflectionClass($nextcloudTestServerHelper);
if ($nextcloudTestServerHelperParameters === null) {

View File

@ -43,20 +43,6 @@ SCENARIO_TO_RUN=$1
composer install
# Although Behat documentation states that using the BEHAT_PARAMS environment
# variable "You can set any value for any option that is available in a
# behat.yml file" this is currently not true for the constructor parameters of
# contexts (see https://github.com/Behat/Behat/issues/983). Thus, the default
# "behat.yml" configuration file has to be adjusted to provide the appropriate
# parameters for NextcloudTestServerContext.
ORIGINAL="\
- NextcloudTestServerContext"
REPLACEMENT="\
- NextcloudTestServerContext:\n\
nextcloudTestServerHelper: NextcloudTestServerLocalHelper\n\
nextcloudTestServerHelperParameters:"
sed "s/$ORIGINAL/$REPLACEMENT/" config/behat.yml > config/behat-local.yml
cd ../../
echo "Installing and configuring Nextcloud server"
@ -72,4 +58,4 @@ cd build/acceptance
echo "Waiting for Selenium"
timeout 60s bash -c "while ! curl 127.0.0.1:4444 >/dev/null 2>&1; do sleep 1; done"
vendor/bin/behat --config=config/behat-local.yml $SCENARIO_TO_RUN
vendor/bin/behat $SCENARIO_TO_RUN