diff --git a/commands/web/behat b/commands/web/behat index 8888048..82c4044 100755 --- a/commands/web/behat +++ b/commands/web/behat @@ -24,5 +24,21 @@ if [ ! -f "bin/behat" ]; then composer install fi -# Run behat with the provided flags/arguments +# Signal to PHP-FPM (via shared filesystem) that behat is running, so settings.php +# can disable modules like captcha and antibot that block automated requests. +touch /var/www/html/web/.behat_testing +trap "rm -f /var/www/html/web/.behat_testing" EXIT INT TERM bin/behat "$@" + +# big_pipe +# Please use following php code in FeatureContext.php to deal with big_pipe module and failing tests: +# +# /** @BeforeSuite */ +# public static function disableBigPipe(): void { +# \Drupal::service('module_installer')->uninstall(['big_pipe']); +# } +# +# /** @AfterSuite */ +# public static function enableBigPipe(): void { +# \Drupal::service('module_installer')->install(['big_pipe']); +# } diff --git a/settings.local.devmode.php b/settings.local.devmode.php index 0b1a43c..e50ec37 100644 --- a/settings.local.devmode.php +++ b/settings.local.devmode.php @@ -191,3 +191,17 @@ if (file_exists($project_settings)) { include $project_settings; } + +// Prepare the environment for tests. The flag file is created by the +// ddev behat command and removed on exit, since env vars are not shared +// between the CLI process and PHP-FPM. +if (file_exists(DRUPAL_ROOT . '/.behat_testing')) { + // Disable captcha during Behat test runs. + $config['captcha.captcha_point.user_login_form']['status'] = FALSE; + // Enable aggregation + $config['system.performance']['css']['preprocess'] = TRUE; + $config['system.performance']['js']['preprocess'] = TRUE; + // Enable advagg. + $config['advagg.settings']['enabled'] = TRUE; + // @todo: Decide on cache-bins for tests +} diff --git a/settings.local.perfmode.php b/settings.local.perfmode.php index 79a5113..31504f2 100644 --- a/settings.local.perfmode.php +++ b/settings.local.perfmode.php @@ -116,3 +116,17 @@ if (file_exists($project_settings)) { include $project_settings; } + +// Prepare the environment for tests. The flag file is created by the +// ddev behat command and removed on exit, since env vars are not shared +// between the CLI process and PHP-FPM. +if (file_exists(DRUPAL_ROOT . '/.behat_testing')) { + // Disable captcha during Behat test runs. + $config['captcha.captcha_point.user_login_form']['status'] = FALSE; + // Enable aggregation + $config['system.performance']['css']['preprocess'] = TRUE; + $config['system.performance']['js']['preprocess'] = TRUE; + // Enable advagg. + $config['advagg.settings']['enabled'] = TRUE; + // @todo: Decide on cache-bins for tests +}