{"id":19351832,"url":"https://github.com/thunder/drupal-testing","last_synced_at":"2026-01-08T13:17:20.567Z","repository":{"id":42568676,"uuid":"237225241","full_name":"thunder/drupal-testing","owner":"thunder","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-14T10:18:52.000Z","size":200,"stargazers_count":5,"open_issues_count":8,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T09:51:13.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thunder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-30T14:01:58.000Z","updated_at":"2025-01-14T10:18:11.000Z","dependencies_parsed_at":"2024-01-17T15:36:51.280Z","dependency_job_id":"39eea464-76df-4c1c-b0af-954a71864ab4","html_url":"https://github.com/thunder/drupal-testing","commit_stats":{"total_commits":121,"total_committers":6,"mean_commits":"20.166666666666668","dds":"0.36363636363636365","last_synced_commit":"ff026e913aea3eb92b8636d00323fc1040b33c11"},"previous_names":[],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunder%2Fdrupal-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunder%2Fdrupal-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunder%2Fdrupal-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thunder%2Fdrupal-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thunder","download_url":"https://codeload.github.com/thunder/drupal-testing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250391138,"owners_count":21422846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T04:37:25.124Z","updated_at":"2026-01-08T13:17:20.507Z","avatar_url":"https://github.com/thunder.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Test Drupal projects\n\n[![Build Status](https://travis-ci.com/thunder/drupal-testing.svg?branch=master)](https://travis-ci.com/thunder/drupal-testing)\n\n# Versions\n\n[![Latest Stable Version](https://poser.pugx.org/thunder/drupal-testing/v/stable)](https://packagist.org/packages/thunder/drupal-testing) \n[![Latest Unstable Version](https://poser.pugx.org/thunder/drupal-testing/v/unstable)](https://packagist.org/packages/thunder/drupal-testing)\n\n# About\n\nUse this package to simplify your drupal project testing. This will run all your standard drupal test and additionally \ncheck your source code for drupal coding style guidelines. It can be used to locally run those tests, or on CI platforms\nlike travis or in github actions. \n\n# Prerequisites\n\nTo get the most out of this package you should consider to add a few things to your module\n\n## Add your module name to the @group annotation of your test classes.\n\nIf your module is called \"my_module\" add the following annotation to your test classes:\n\n    /**\n     * Tests for my_module.\n     *\n     * @group my_module\n     */\n    class MyModuleTest extends ...\n\n## Add a composer.json to your module. \nWe use that file to automate different things. We parse the module name from it and we will automatically download \nrequired drupal modules before running the tests.\n\nA composer.json could look like the following:\n\n    {\n        \"name\": \"drupal/my_module\",\n        \"description\": \"The description of my_module\",\n        \"type\": \"drupal-module\",\n        \"license\": \"GPL-2.0-or-later\",\n        \"require\": {\n            \"drupal/another_module\": \"^2.0\"\n        }\n    }\n\n## Do not use deprecated TestBase classes\nOnly not deprecated (as of drupal 8.6) TestBase classes are tested. Especially the deprecated JavascriptTestBase\nis not supported, please use WebDriverTestBase instead. See [JavascriptTestBase is deprecated in favor of WebDriverTestBase](https://www.drupal.org/node/2945059)\n\n# Setup\nMake sure, that you have bash 4 installed or greater. On most systems this will be the case. But on MacOS you need to\nupdate the build-in bash with homebrew. \n\nOther requirements:\n\n    - [jq](https://stedolan.github.io/jq/)\n    - PHP \u003e 7.2 + extensions needed by Drupal + sqlite extension, if no other database is used.\n    - [composer](https://getcomposer.org/)\n    - [node + npm](https://nodejs.org/en/)\n \nFor using drupal-testing on travis all you need to do is to copy the [.travis.yaml.dist](https://github.com/thunder/drupal-testing/blob/master/.travis.yml.dist) \nto your project root folder and rename it to .travis.yaml. If your module meets all the prerequisites, you should be done. Otherwise you might need to provide some environment variables.\nSee below for possible configurations.   \n\n# Differences to LionsAd/drupal_ti\nWhile the general approach is very similar to drupal_ti, we differ in some regards.\n \n - If you want to run deprecated TestBase classes, or if you want to run behat tests, use drupal_ti.\n - When using WebDriverTestBase and Drupal \u003e 8.6 (which needs selenium instead of phantom.js) use this package.\n - If you want a simple travis.yml file, that works without any configuration, use this package.\n - You can directly use this for quickly running the tests locally and on other CI environments as well! Just do \n   \u003ccode\u003ecomposer global require thunder/drupal-testing\u003c/code\u003e add the global composer directory to your $PATH and call \n   \u003ccode\u003etest-drupal-project\u003c/code\u003e from within your modules directory. Everything will be build, installed and tested\n   automatically.\n \n# Configuration\n\nWe try to run without configuration as much as possible. But we still have a lot of configuration options, if your module\nrequires some special treatment, or if your testing environment is not travis/github (or they changed some default values).\n\n## Steps\nThe simplest way to run the tests is to just call \u003ccode\u003etest_drupal_project\u003c/code\u003e in your .travis.yml. \nThis will do everything, but it is actually divided into several steps which can be called separately by providing the\nstep as a parameter: \u003ccode\u003etest_drupal_project build\u003c/code\u003e would call the build step and any steps that the build step\ndepends on. Steps, that have already been executed will not be called again on subsequent call. So, if you call\n\u003ccode\u003etest_drupal_project start_services\u003c/code\u003e next, all steps up to the build step will not be executed.\n\nThe steps are the following:\n\n### requirements\nCheck if testing requirements are met. \n\n### coding_style\nTests php and javascript coding styles\n\n### prepare_build\nCreates a drupal project and modifies the composer.json to contain the required modules.\n\n### build\nBuilds the drupal installation with drupal project, adds all dependencies from the module and calls composer install.\n\n### install\nInstalls drupal with the minimal profile or the one that has been configured.\n\n### start_services\nStarts services required for testing. Starts web server and selenium.\n\n### run_tests\nRuns the tests\n  \nThis is also the order of the step dependencies, coding_style depends on prepare, build depends on coding_style and\nprepare, and so on.\n\nA very common use case for splitting the execution into steps is to stop after the build step, and add custom build\noperations (e.g. downloading dependencies, that cannot be installed by composer) and then continue later.\nAn example for such a custom .travis.yml would be:\n\n    language: php\n    sudo: required\n\n    cache:\n      apt: true\n      directories:\n      - \"$HOME/.composer/cache\"\n      - \"$HOME/.drush/cache\"\n      - \"$HOME/.npm\"\n\n    php:\n      - 7.2\n\n    branches:\n      only:\n        - /^8\\.([0-9]+|x)\\-[0-9]+\\.([0-9]+|x)$/\n\n    env:\n      global:\n        - PATH=\"$PATH:$HOME/.composer/vendor/bin\"\n\n    before_install:\n      - composer global require thunder/drupal-testing\n\n    install:\n      - test-drupal-project build\n      # Download something to the ccurrent directory.\n      - wget -qO- https://www.some-domain.com/some-needed-dependency.tar.gz | tar xvz\n\n    script:\n      # this continues after the build step and finishes testing.\n      - test-drupal-project\n\n# Environment variables\n\nYou can configure your tests with several environment variables, most of them are only needed, if you want to run the\ntests in different environments then travis. You can change database credentials, server hosts and ports, some\ninstallation paths and the test setup. All those variables should work out of the box when running on travis with\na module, that has a correct composer.json and the test group set to the module name (see prerequisites for more\ninformation). Variables can be set in the env section of the .travis.yml.\n\n## Available variables\n\nFind all defined variables in [configuration.sh](https://github.com/thunder/drupal-testing/blob/master/configuration.sh)\n\nSome interesting variables are:\n\n- DRUPAL_TESTING_PROJECT_BASEDIR\n\nThe directory, where the project is located. On travis this is set to TRAVIS_BUILD_DIR otherwise defaults to the current\ndirectory.\n\n- DRUPAL_TESTING_COMPOSER_NAME\n\nThe composer name of the current project, if not specified, it will be read from the composer.json.\n\n- DRUPAL_TESTING_PROJECT_NAME\n\nThe project name, if not provided, the second part of the composer name will be use. E.g. If the composer name is\nvendor/myproject the project name will be myproject. This will be used as default test group.\n\n- DRUPAL_TESTING_TEST_GROUP\n\nThe phpunit test group, defaults to the value of ${DRUPAL_TESTING_PROJECT_NAME}. To provide multiple groups,\nconcatenate them with comma:  DRUPAL_TESTING_TEST_GROUP=\"mygroup1,mygroup2\"\n\n- DRUPAL_TESTING_TEST_GROUP_EXCLUDE\n\nThe phpunit test groups to exclude, defaults an empty string. To provide multiple groups,\nconcatenate them with comma:  DRUPAL_TESTING_TEST_GROUP_EXCLUDE=\"mygroup1,mygroup2\"\n\n- DRUPAL_TESTING_TEST_FILTER\n\nOnly runs tests whose name matches the given regular expression pattern. \nExample: DRUPAL_TESTING_TEST_FILTER=TestCaseClass::testMethod\n\n- DRUPAL_TESTING_TEST_CODING_STYLES\n\nBoolean value if coding styles should be tested with burdamagazinorg/thunder-dev-tools.\nBy default coding styles are tested.\n\n- DRUPAL_TESTING_TEST_JAVASCRIPT\n- DRUPAL_TESTING_TEST_PHP\n\nBoolean values if javascript and php coding styles should be tested. By default all coding styles are tested.\n\n- DRUPAL_TESTING_TEST_BASE_DIRECTORY\n\nThe base directory for all generated files. Drupal will be installed into this directory. This directory and its \ncontents get removed after a successful tests.\n\n- DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY\n\nThe directory, where drupal will be installed, defaults to ${DRUPAL_TESTING_TEST_BASE_DIRECTORY}/install\nThis directory gets removed after successful tests.\n\n- DRUPAL_TESTING_HTTP_HOST\n- DRUPAL_TESTING_HTTP_PORT\n\nThe web server host and port. Defaults to 127.0.0.1 and 8888\n\n- DRUPAL_TESTING_SELENIUM_CHROME_VERSION\n\nThe selenium chrome docker version to use. defaults to the latest version.\n\n- DRUPAL_TESTING_SELENIUM_HOST\n- DRUPAL_TESTING_SELENIUM_PORT\n\nThe selenium host and port. Defaults to the web server host and port 4444.\n\n- DRUPAL_TESTING_DATABASE_HOST\n- DRUPAL_TESTING_DATABASE_PORT\n- DRUPAL_TESTING_DATABASE_USER\n- DRUPAL_TESTING_DATABASE_PASSWORD\n- DRUPAL_TESTING_DATABASE_NAME\n\nThe database information. Defaults to the web server host, port 3306, user testing and empty password. The database name\nis set to testing. If you run your tests locally, you might want to change these to your local mysql installation.\n\n- DRUPAL_TESTING_CLEANUP\n\nBy default all created files are deleted after successful test runs, you can disable this behaviour by setting\nthis to false.\n\n- SYMFONY_DEPRECATIONS_HELPER\n\nThe symfony environment variable to ignore deprecations, for possible values see\n[PHPUnit Bridge documentation](https://symfony.com/doc/3.4/components/phpunit_bridge.html).\nThe default value is \"week\" to ignore any deprecation notices.\n\n- MINK_DRIVER_ARGS_WEBDRIVER\n\nThe driver args for webdriver. You might change this, when running your own chromedriver / selenium instance.\n\nExample .travis.yml with some variables set:\n\n    language: php\n    dist: xenial\n    \n    php:\n      - 7.2\n    \n    services:\n      - mysql\n    \n    cache:\n      apt: true\n      directories:\n      - \"$HOME/.composer/cache\"\n      - \"$HOME/.drush/cache\"\n      - \"$HOME/.npm\"\n\n    branches:\n      only:\n        - /^8\\.([0-9]+|x)\\-[0-9]+\\.([0-9]+|x)$/\n\n    env:\n      matrix:\n        # Add a test matrix where tests are running once with deprecations failing and once without.\n        # The test with deprecation warnings is allowed to fail.\n        - SYMFONY_DEPRECATIONS_HELPER=weak\n        - SYMFONY_DEPRECATIONS_HELPER=0\n      global:\n        - PATH=\"$PATH:$HOME/.composer/vendor/bin\"\n\n    matrix:\n      allow_failures:\n        - env: SYMFONY_DEPRECATIONS_HELPER=0\n\n    before_install:\n      - composer global require thunder/drupal-testing\n\n    script:\n      - test-drupal-project\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthunder%2Fdrupal-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthunder%2Fdrupal-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthunder%2Fdrupal-testing/lists"}