Skip to content

Commit

Permalink
Inject values from .environment into php-fpm environment, fixes #89 (#99
Browse files Browse the repository at this point in the history
)

* Inject values from .environment into php-fpm environment, fixes #89
* Add test for wordpress-bedrock
* Add capability of loading a test db (and do it with wordpress-bedrock
  • Loading branch information
rfay authored Mar 10, 2023
1 parent f60d73f commit 5cb7643
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
10 changes: 9 additions & 1 deletion install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pre_install_actions:
- |
#ddev-nodisplay
#ddev-description:Checking DDEV version
(ddev debug capabilities | grep migrate-database >/dev/null) || (echo "Please upgrade DDEV to v1.21.1+ for appropriate capabilities" && false)
(ddev debug capabilities | grep web-start-hooks >/dev/null) || (echo "Please upgrade DDEV to v1.21.5+ for appropriate capabilities" && false)
- |
#ddev-nodisplay
Expand Down Expand Up @@ -137,6 +137,14 @@ post_install_actions:
;;
esac
- |
#ddev-nodisplay
#ddev-description: Install .environment file into web-entrypoint.d if needed
if [ -f ../.environment ]; then
mkdir -p web-entrypoint.d
cp ../.environment web-entrypoint.d/environment.sh
fi
# Write a config.platformsh.yaml based on calculated values, php version, database, docroot
- |
#ddev-nodisplay
Expand Down
3 changes: 3 additions & 0 deletions tests/per_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ per_test_setup() {
ddev get ${PROJECT_SOURCE}
echo "# doing ddev restart with template ${template} PROJNAME=${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev restart >/dev/null
if [ -f ${PROJECT_SOURCE}/tests/testdata/${template}/db.sql.gz ]; then
ddev import-db --src=${PROJECT_SOURCE}/tests/testdata/${template}/db.sql.gz
fi
}

per_test_teardown() {
Expand Down
Binary file added tests/testdata/wordpress-bedrock/db.sql.gz
Binary file not shown.
32 changes: 32 additions & 0 deletions tests/wordpress-bedrock.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Requires bats-assert and bats-support
# brew tap kaos/shell &&
# brew install bats-core bats-assert bats-support jq mkcert yq
setup() {
load setup.sh
}

teardown() {
load teardown.sh
}

@test "wordpress-bedrock" {
load per_test.sh
template="wordpress-bedrock"
for source in $PROJECT_SOURCE ddev/ddev-platformsh; do
per_test_setup
printf "<?php\nprint 'DB_USER=' . getenv('DB_USER') . ' DB_PASSWORD=' . getenv('DB_PASSWORD');" >web/phpinfo.php
run curl -s http://${PROJNAME}.ddev.site/phpinfo.php
assert_line "DB_USER=db DB_PASSWORD=db"
curl -s http://${PROJNAME}.ddev.site | grep "Mindblown: a blog about"
run ddev exec -s db 'echo ${DDEV_DATABASE}'
assert_output "mariadb:10.4"
run ddev exec 'echo $PLATFORM_RELATIONSHIPS | base64 -d | jq -r ".database[0].username"'
assert_output "db"
run ddev exec "php --version | awk 'NR==1 { sub(/\.[0-9]+$/, \"\", \$2); print \$2 }'"
assert_output "8.1"
ddev describe -j >describe.json
run jq -r .raw.docroot <describe.json
assert_output "web"
per_test_teardown
done
}

0 comments on commit 5cb7643

Please sign in to comment.