Skip to content

iVegas/docker4drupal_phpunit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Steps of docker-compose project configuration

  1. Default Docker4Drupal stack (.env, docker-compose.yml files). Can be modified, but for this configuration nginx container is required; https://github.com/wodby/docker4drupal
  2. Copy docker-compose.override.yml file from this gist to the same folder along with docker-compose.yml file.
  3. Clone drupal repo into web directory.
    git clone --branch 8.8.x https://git.drupalcode.org/project/drupal.git web
    cd web
  4. Run containers:
    docker-compose up
    Note: Always run the containers before the tests run.
  5. Install Drupal dependencies:
    docker-compose exec php bash -c "cd web && composer install"
  6. Define settings.php file:
    cp web/sites/default/default.settings.php web/sites/default/settings.php
  7. Set database connection:
    cat >> web/sites/default/settings.php << EOL
    
    \$databases['default']['default'] = [
      'database' => getenv('DB_NAME'),
      'username' => getenv('DB_USER'),
      'password' => getenv('DB_PASSWORD'),
      'host' => getenv('DB_HOST'),
      'port' => '3306',
      'driver' => getenv('DB_DRIVER'),
    ];
    EOL

Steps of PHPStorm configuration

  1. Open project directory.

  2. Go to Settings.

  3. Define interpreter from docker-compose stack.

    Step of PHP interpreter setup Define PHP interpreter from docker-compose file Define additional option of the connectivity

  4. Configure the PHPUnit

    Define PHPUnit by remote interpreter Choose remote interpreter Define Drupal specific configuration

Setup demo site

docker-compose exec php bash -c "cd web && drush si demo_umami --account-pass=admin -y"

Test run

  1. Choose one of the test from Drupal Core.

    Note: Nightwatch tests not covered by this configuration.

  2. Launch test from the PHPStorm UI.

    Go to the test and find the launch button step 1. Example of the UnitTestCase based test class Go to the test and find the launch button step 2 We can see the successfully finished test results Example of the failed tests Multiple tests run. Example of the KernelTestBase based test class Example of the BrowserTestBase based test class Example of the WebDriverTestBase based test class

About

PHPUnit configuration for Docker4Drupal stack

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published