Skip to content

Commit b61868d

Browse files
authored
SUT improvements - nothing for end users (#3728)
* SUT improvements - nothing for end users Recognize .env files add composer "sut" script * Move load.environment.php to /tests for scenarios benefit * Document docker env in Contributing. * Add changed scenarios. * Remove --keep. * Add vlucas/phpdotenv to --keep * CS
1 parent 1764553 commit b61868d

File tree

7 files changed

+50
-19
lines changed

7 files changed

+50
-19
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Drush is built by people like you! Please [join us](https://github.com/drush-ops
77
* Test before you push. Get familiar with Unish, our test suite. See the test-specific [README.md](tests/README.md). Optionally run tests in the provided Docker containers.
88
* We maintain branches named 9.x, 8.x, etc. These are release branches. From these branches, we make new tags for patch and minor versions.
99

10+
## Development Environment
11+
* You may choose to use the docker-compose file in root directory for an optimized environment.
12+
* See `composer run-script -l` for a list of helper scripts.
13+
1014
## Coding style
1115
* Do write comments. You don't have to comment every line, but if you come up with something thats a bit complex/weird, just leave a comment. Bear in mind that you will probably leave the project at some point and that other people will read your code. Undocumented huge amounts of code are nearly worthless!
1216
* We use [PSR-2](http://www.php-fig.org/psr/psr-2/) in the /src directory. [Drupal's coding standards](https://drupal.org/coding-standards) are still used in the includes directory (deprecated code).

composer.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
"webflo/drupal-core-strict": "8.6.x-dev",
6464
"drupal/empty_theme": "1.0",
6565
"drupal/devel": "^1.0@RC",
66-
"drupal/alinks": "1.0.0"
66+
"drupal/alinks": "1.0.0",
67+
"vlucas/phpdotenv": "^2.4"
6768
},
6869
"autoload": {
6970
"psr-4": {
@@ -75,7 +76,8 @@
7576
"autoload-dev": {
7677
"psr-4": {
7778
"Drush\\": "isolation/src/"
78-
}
79+
},
80+
"files": ["tests/load.environment.php"]
7981
},
8082
"config": {
8183
"optimize-autoloader": true,
@@ -103,11 +105,12 @@
103105
"api": "PATH=$HOME/bin:$PATH sami.phar --ansi update sami-config.php",
104106
"sami-install": "mkdir -p $HOME/bin && curl --output $HOME/bin/sami.phar http://get.sensiolabs.org/sami.phar && chmod +x $HOME/bin/sami.phar",
105107
"scenario": "scenarios/install",
106-
"si-unish": "./drush site:install testing --uri=dev --sites-subdir=dev --db-url=mysql://root:password@mariadb/unish_dev -v",
108+
"sut": "./drush --uri=dev",
109+
"sut:si": "./drush site:install testing --uri=dev --sites-subdir=dev --db-url=mysql://root:password@mariadb/unish_dev -v",
107110
"unit": "phpunit --colors=always",
108111
"functional": "phpunit --colors=always --configuration tests",
109112
"post-update-cmd": [
110-
"create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|sebastian/version\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'",
113+
"create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|vlucas/phpdotenv\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'",
111114
"create-scenario isolation-phpunit4 --base isolation --autoload-dir isolation --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'"
112115
]
113116
},

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ services:
1313

1414
# More info at https://github.com/wodby/php
1515
# We don't want their drupal-php image as that ships with a Drush inside.
16-
php:
16+
drupal:
1717
image: wodby/php:${PHP_TAG-7.2-dev}
18-
container_name: ${PROJECT_NAME-unish}_php
18+
container_name: ${PROJECT_NAME-unish}_drupal
1919
environment:
2020
PHP_SENDMAIL_PATH: /dev/null
2121
UNISH_DB_URL: ${UNISH_DB_URL-mysql://root:password@mariadb}

scenarios/isolation-phpunit4/composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
},
4343
"require-dev": {
4444
"lox/xhprof": "dev-master",
45-
"phpunit/phpunit": "^4.8.36"
45+
"phpunit/phpunit": "^4.8.36",
46+
"vlucas/phpdotenv": "^2.4"
4647
},
4748
"autoload": {
4849
"psr-4": {
@@ -54,7 +55,8 @@
5455
"autoload-dev": {
5556
"psr-4": {
5657
"Drush\\": "isolation/src/"
57-
}
58+
},
59+
"files": ["tests/load.environment.php"]
5860
},
5961
"config": {
6062
"optimize-autoloader": true,
@@ -67,8 +69,8 @@
6769
"vendor-dir": "../../vendor"
6870
},
6971
"scripts": {
70-
"cs": "phpcs -n --standard=PSR2 src tests examples",
71-
"cbf": "phpcbf -n --standard=PSR2 src tests examples",
72+
"cs": "phpcs",
73+
"cbf": "phpcbf",
7274
"lint": [
7375
"find includes -name '*.inc' -print0 | xargs -0 -n1 php -l",
7476
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
@@ -83,10 +85,12 @@
8385
"api": "PATH=$HOME/bin:$PATH sami.phar --ansi update sami-config.php",
8486
"sami-install": "mkdir -p $HOME/bin && curl --output $HOME/bin/sami.phar http://get.sensiolabs.org/sami.phar && chmod +x $HOME/bin/sami.phar",
8587
"scenario": "scenarios/install",
88+
"sut": "./drush --uri=dev",
89+
"sut:si": "./drush site:install testing --uri=dev --sites-subdir=dev --db-url=mysql://root:password@mariadb/unish_dev -v",
8690
"unit": "phpunit --colors=always",
8791
"functional": "phpunit --colors=always --configuration tests",
8892
"post-update-cmd": [
89-
"create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|sebastian/version\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'",
93+
"create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|vlucas/phpdotenv\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'",
9094
"create-scenario isolation-phpunit4 --base isolation --autoload-dir isolation --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'"
9195
]
9296
},

scenarios/isolation/composer.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
},
4343
"require-dev": {
4444
"lox/xhprof": "dev-master",
45-
"phpunit/phpunit": "^5.5.4"
45+
"phpunit/phpunit": "^5.5.4",
46+
"vlucas/phpdotenv": "^2.4"
4647
},
4748
"autoload": {
4849
"psr-4": {
@@ -54,7 +55,8 @@
5455
"autoload-dev": {
5556
"psr-4": {
5657
"Drush\\": "isolation/src/"
57-
}
58+
},
59+
"files": ["tests/load.environment.php"]
5860
},
5961
"config": {
6062
"optimize-autoloader": true,
@@ -67,8 +69,8 @@
6769
"vendor-dir": "../../vendor"
6870
},
6971
"scripts": {
70-
"cs": "phpcs -n --standard=PSR2 src tests examples",
71-
"cbf": "phpcbf -n --standard=PSR2 src tests examples",
72+
"cs": "phpcs",
73+
"cbf": "phpcbf",
7274
"lint": [
7375
"find includes -name '*.inc' -print0 | xargs -0 -n1 php -l",
7476
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
@@ -83,10 +85,12 @@
8385
"api": "PATH=$HOME/bin:$PATH sami.phar --ansi update sami-config.php",
8486
"sami-install": "mkdir -p $HOME/bin && curl --output $HOME/bin/sami.phar http://get.sensiolabs.org/sami.phar && chmod +x $HOME/bin/sami.phar",
8587
"scenario": "scenarios/install",
88+
"sut": "./drush --uri=dev",
89+
"sut:si": "./drush site:install testing --uri=dev --sites-subdir=dev --db-url=mysql://root:password@mariadb/unish_dev -v",
8690
"unit": "phpunit --colors=always",
8791
"functional": "phpunit --colors=always --configuration tests",
8892
"post-update-cmd": [
89-
"create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|sebastian/version\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'",
93+
"create-scenario isolation --autoload-dir isolation --autoload-dir internal-copy --keep '\\(psr/log\\|consolidation/config\\|site-alias\\|var-dumper\\|symfony/finder\\|drupal-finder\\|path-util\\|vlucas/phpdotenv\\|xhprof\\)' 'phpunit/phpunit:^5.5.4'",
9094
"create-scenario isolation-phpunit4 --base isolation --autoload-dir isolation --autoload-dir internal-copy 'phpunit/phpunit:^4.8.36'"
9195
]
9296
},

src/Commands/core/SiteInstallCommands.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ public function install(array $profile, $options = ['db-url' => self::REQ, 'db-p
132132
}
133133

134134
$msg = 'Starting Drupal installation. This takes a while.';
135-
if (is_null($options['notify'])) {
136-
$msg .= ' Consider using the --notify global option.';
137-
}
138135
$this->logger()->notice(dt($msg));
139136

140137
// Define some functions which alter away the install_finished task.

tests/load.environment.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/**
4+
* This file is included very early. See autoload.files in composer.json and
5+
* https://getcomposer.org/doc/04-schema.md#files
6+
*/
7+
8+
use Dotenv\Dotenv;
9+
use Dotenv\Exception\InvalidPathException;
10+
11+
/**
12+
* Load any .env file. See /.env.example.
13+
*/
14+
$dotenv = new Dotenv(__DIR__);
15+
try {
16+
$dotenv->load();
17+
} catch (InvalidPathException $e) {
18+
// Do nothing. Production environments rarely use .env files.
19+
}

0 commit comments

Comments
 (0)