Skip to content

Instantly share code, notes, and snippets.

@agentolivia
Forked from juampynr/README.md
Created March 31, 2022 03:46
Show Gist options
  • Save agentolivia/ca9851e12d2205c85126879fe92a2ddc to your computer and use it in GitHub Desktop.
Save agentolivia/ca9851e12d2205c85126879fe92a2ddc to your computer and use it in GitHub Desktop.
Run Drupal 8 web tests without installing Drupal
  1. Create a MySQL database.
  2. Create a user that has access to that database.
  3. Make sure that you have the PDO_MySQL PHP library (otherwise you will get an error because it is missing).
  4. Run the following script.
  5. Once tests complete, we need to stop PHP's web server.

Note: there seem to be some issues with PHP's built-in web server. Please report them here https://www.drupal.org/node/1543858.

# Next, download core and run web tests.
wget -q -O - http://ftp.drupal.org/files/projects/drupal-8.1.x-dev.tar.gz | tar xz
mv my_module drupal-8.1.x-dev/modules/
cd drupal-8.1.x-dev
# You need to download the module's dependencies. Perhaps Composer can do this?
drush dl ctools
# Start PHP's built-in web server in the background.
nohup php -S localhost:9000 > phpd.log 2>&1 &
# Run tests.
php ./core/scripts/run-tests.sh --sqlite /tmp/test.sqlite --dburl mysql://user:pass@localhost/db_name --url http://localhost:9000 --module my_module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment