Giter Club home page Giter Club logo

drainpipe-dev's Introduction

Drainpipe

See https://github.com/lullabot/drainpipe first.

This is a composer package containing the testing helpers for Drainpipe i.e. should be included in require-dev and not installed in production environments.

Installation

  • Your Drupal project must be using drupal/core-composer-scaffold
  • Run:
    composer config extra.drupal-scaffold.gitignore true
    composer config --json --merge extra.drupal-scaffold.allowed-packages '["lullabot/drainpipe-dev"]'
    
    or if using DDEV:
    ddev composer config extra.drupal-scaffold.gitignore true
    ddev composer config --json extra.drupal-scaffold.allowed-packages \[\"lullabot/drainpipe-dev\"]
    
  • Ensure your project's composer.json now contains the following:
    "extra": {
      "drupal-scaffold": {
          "gitignore": true,
          "allowed-packages": [
              "lullabot/drainpipe-dev"
          ]
      }
    }
    
  • Run composer require lullabot/drainpipe-dev --dev

Usage

test:static

Runs all static tests i.e. those which don't require a running Drupal environment.

The static tests consist of:

test:security

Runs security checks for composer packages against the FriendsOfPHP Security Advisory Database and Drupal core and contributed modules against Drupal's Security Advisories.

test:lint

  • YAML lint on .yml files in the web directory
  • Twig lint on files in web/modules, web/profiles, and web/themes
  • composer validate

These cannot currently be customised. See #9.

test:phpstan

Runs PHPStan with mglaman/phpstan-drupal on web/modules/custom, web/themes/custom, and web/sites.

test:phpunit

Runs PHPUnit tests in:

  • web/modules/custom/**/tests/src/Unit
  • test/phpunit/**/Unit
  • web/modules/custom/**/tests/src/Kernel
  • test/phpunit/**/Kernel
  • web/modules/custom/**/tests/src/Functional
  • test/phpunit/**/Functional
  • web/modules/custom/**/tests/src/FunctionalJavaScript
  • test/phpunit/**/FunctionalJavaScript

When running the main test task, this is split into test:phpunit:functional and test:phpunit:static.

Support for DTT is included, just set this in your Taskfile.yml:

vars:
  DRUPAL_TEST_TRAITS: true

This will additionally look for tests in:

  • web/modules/custom/**/tests/src/ExistingSite
  • test/phpunit/**/ExistingSite
  • web/modules/custom/**/tests/src/ExistingSiteJavascript
  • test/phpunit/**/ExistingSiteJavascript

You will need to ensure a running Drupal site is available for running DTT tests, e.g. by running the site installer.

test:phpcs

Runs PHPCS with Drupal coding standards provided by Coder module.

test:functional

Runs all functional tests i.e. those which require a running Drupal environment.

test:config

Verifies that exported configuration matches the current configuration in Drupal's database.

test:nightwatch:setup

This will help you setup your project to run Nightwatch tests by installing the necessary node packages and DDEV configurations.

test:nightwatch

Runs functional browser tests with Nightwatch.

If you are using DDEV, Drainpipe will have created a .ddev/docker-compose.selenium.yaml file that provides Firefox and Chrome as containers, as well as an example test in test/nightwatch/example.nightwatch.js.

To run the above test you will need to have a working Drupal installation in the Firefox and Chrome containers. You can run the test:nightwatch:siteinstall helper task to run the Drupal site installer for both sites with your existing configuration.

After you've verified this test works, you can ignore it in your composer.json:

"extra": {
        "drupal-scaffold": {
            "file-mapping": {
                "[project-root]/test/nightwatch/example.nightwatch.js": {
			"mode": "skip"
		}
	}
}

Nightwatch tests must have the suffix .nightwatch.js to be recognised by the test runner.

Whilst tests are running, you can view them in realtime through your browser.

https://:7900 for Chrome https://:7901 for Firefox

The password for all environments is secret.

test:autofix

Attempts to autofix any issues discovered by tests. Currently, this is just fixing PHPCS errors with PHPCBF.

drainpipe-dev's People

Contributors

justafish avatar deviantintegral avatar plopesc avatar hawkeyetwolf avatar geekygnr avatar rabbitlair avatar edutrul avatar rigoucr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.