Skip to content

Commit 90eeb91

Browse files
committed
feat: Allow installing and testing with all database types
1 parent 66a2631 commit 90eeb91

File tree

6 files changed

+327
-285
lines changed

6 files changed

+327
-285
lines changed

README.md

Lines changed: 90 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,90 @@
1-
# ddev-core-dev
2-
3-
This is a DDEV addon for doing Drupal core development.
4-
5-
We're in #ddev-for-core-dev on [Drupal Slack](https://www.drupal.org/community/contributor-guide/reference-information/talk/tools/slack) (but please try and keep work and feature requests in Issues where it's visible to all 🙏)
6-
7-
```
8-
git clone https://git.drupalcode.org/project/drupal.git drupal
9-
cd drupal
10-
ddev config --omit-containers=db --disable-settings-management
11-
ddev start
12-
ddev get justafish/ddev-drupal-core-dev
13-
ddev restart
14-
ddev composer install
15-
16-
# See included commands
17-
ddev drupal list
18-
19-
# Install drupal
20-
ddev drupal install
21-
22-
# Run PHPUnit tests
23-
ddev phpunit core/modules/sdc
24-
25-
# Run Nightwatch tests (currently only runs on Chrome)
26-
ddev nightwatch --tag core
27-
```
28-
29-
## Nightwatch Examples
30-
31-
You can watch Nightwatch running in real time at https://drupal.ddev.site:7900
32-
for Chrome and https://drupal.ddev.site:7901 for Firefox. The password is
33-
"secret". YMMV using Firefox as core tests don't currently run on it.
34-
35-
Only core tests
36-
```
37-
ddev nightwatch --tag core
38-
```
39-
40-
Skip running core tests
41-
```
42-
ddev nightwatch --skiptags core
43-
```
44-
45-
Run a single test
46-
```
47-
ddev nightwatch tests/Drupal/Nightwatch/Tests/exampleTest.js
48-
```
49-
50-
a11y tests for both the admin and default themes
51-
```
52-
ddev nightwatch --tag a11y
53-
```
54-
55-
a11y tests for the admin theme only
56-
```
57-
ddev nightwatch --tag a11y:admin
58-
```
59-
60-
a11y tests for the default theme only
61-
```
62-
ddev nightwatch --tag a11y:default
63-
```
64-
65-
a11y test for a custom theme used as the default theme
66-
```
67-
ddev nightwatch --tag a11y:default --defaultTheme bartik
68-
```
69-
70-
a11y test for a custom admin theme
71-
```
72-
ddev nightwatch --tag a11y:admin --adminTheme seven
73-
```
1+
# ddev-core-dev
2+
3+
This is a DDEV addon for doing Drupal core development.
4+
5+
We're in #ddev-for-core-dev on [Drupal Slack](https://www.drupal.org/community/contributor-guide/reference-information/talk/tools/slack) (but please try and keep work and feature requests in Issues where it's visible to all 🙏)
6+
7+
`ddev drush` is fully supported, along with using or testing MariaDB, MySQL, and PostgreSQL databases (and Sqlite3)
8+
9+
10+
```
11+
git clone https://git.drupalcode.org/project/drupal.git drupal
12+
cd drupal
13+
ddev config --project-type=drupal
14+
ddev get justafish/ddev-drupal-core-dev
15+
ddev restart
16+
ddev composer install
17+
ddev config --update
18+
19+
20+
# Install drupal
21+
ddev drush si -y --account-pass==admin
22+
23+
# Run PHPUnit tests
24+
ddev phpunit core/modules/sdc
25+
26+
# Run Nightwatch tests (currently only runs on Chrome)
27+
ddev nightwatch --tag core
28+
```
29+
30+
## Using various database types
31+
32+
By default, the DDEV default database type is used (MariaDB).
33+
34+
To use another supported database type,
35+
`ddev delete -Oy` and `ddev config --database=mysql:8.0` or `ddev config --database=postgres:16` for example.
36+
37+
To use Sqlite,
38+
```
39+
ddev stop
40+
ddev config --disable-settings-management --omit-containers=db
41+
rm -rf web/sites/default/settings*.php web/sites/default/files
42+
ddev start
43+
ddev drupal install
44+
```
45+
46+
## Nightwatch Examples
47+
48+
You can watch Nightwatch running in real time at https://drupal.ddev.site:7900
49+
for Chrome and https://drupal.ddev.site:7901 for Firefox. The password is
50+
"secret". YMMV using Firefox as core tests don't currently run on it.
51+
52+
Only core tests
53+
```
54+
ddev nightwatch --tag core
55+
```
56+
57+
Skip running core tests
58+
```
59+
ddev nightwatch --skiptags core
60+
```
61+
62+
Run a single test
63+
```
64+
ddev nightwatch tests/Drupal/Nightwatch/Tests/exampleTest.js
65+
```
66+
67+
a11y tests for both the admin and default themes
68+
```
69+
ddev nightwatch --tag a11y
70+
```
71+
72+
a11y tests for the admin theme only
73+
```
74+
ddev nightwatch --tag a11y:admin
75+
```
76+
77+
a11y tests for the default theme only
78+
```
79+
ddev nightwatch --tag a11y:default
80+
```
81+
82+
a11y test for a custom theme used as the default theme
83+
```
84+
ddev nightwatch --tag a11y:default --defaultTheme bartik
85+
```
86+
87+
a11y test for a custom admin theme
88+
```
89+
ddev nightwatch --tag a11y:admin --adminTheme seven
90+
```

config.core-dev.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# #ddev-generated
2+
# This file is placed by the justafish/ddev-drupal-core-dev addon.
3+
4+
webimage_extra_packages: ["chromium-driver"]
5+
ddev_version_constraint: '>=v1.23.0'
6+
hooks:
7+
post-start:
8+
- exec: |
9+
dburl='sqlite://localhost/sites/default/files/db.sqlite'
10+
cp .ddev/core-dev/phpunit-chrome.xml core/phpunit.xml
11+
cp .ddev/core-dev/.env core/.env
12+
if ping -c 1 db >/dev/null 2>&1; then
13+
case ${DDEV_DATABASE_FAMILY:-} in
14+
mysql)
15+
# the backslash here is to prevent perl from eating the @
16+
dburl='mysql://db:db\@db/db'
17+
;;
18+
postgres)
19+
dburl='pgsql://db:db\@db/db'
20+
;;
21+
esac
22+
fi
23+
perl -pi -e "s|SIMPLETEST_DB_VALUE|${dburl}|g" core/phpunit.xml
24+
perl -pi -e "s|DRUPAL_TEST_DB_URL_VALUE|${dburl}|g" core/.env
25+
perl -pi -e "s|DRUPAL_CORE_DDEV_URL|${DDEV_PRIMARY_URL}|g" core/phpunit.xml
26+
27+
upload_dirs:
28+
# The install technique tries to remove all of sites/default/files
29+
# but with DDEV + mutagen that isn't possible.
30+
# so just redirect the upload_dirs.
31+
- .ddev/tmp

core-dev/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DRUPAL_TEST_BASE_URL=http://web
1919

2020
# By default we use sqlite as database. Use
2121
# mysql://username:password@localhost/databasename#table_prefix for mysql.
22-
DRUPAL_TEST_DB_URL=sqlite://localhost/sites/default/files/db.sqlite
22+
DRUPAL_TEST_DB_URL=DRUPAL_TEST_DB_URL_VALUE
2323

2424
#############
2525
# Webdriver #

0 commit comments

Comments
 (0)