Skip to content

Commit

Permalink
refactor: move common code back to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
hanoii committed Oct 8, 2024
1 parent 80f4259 commit 180ae7e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 49 deletions.
32 changes: 1 addition & 31 deletions tests/_common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,16 @@ _common_setup() {
cd ${TESTDIR}
ddev config --project-name=${PROJNAME} --project-type=drupal --docroot=web
echo -e "web_environment:\n - DRUPAL_CORE=^${TEST_DRUPAL_CORE}" > .ddev/config.~overrides.yaml
ddev get ${DIR}
}

_common_teardown() {
ddev delete -Oy ${PROJNAME} >/dev/null 2>&1
[ "${TESTDIR}" != "" ] && rm -rf ${TESTDIR}
}

_common_test_install() {
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${DIR}
ddev start
}

_common_test_poser() {
ddev poser
ddev mutagen sync
ls -la
}

_common_test_symlink() {
ddev symlink-project
ddev mutagen sync
ls -la web/modules/custom/test_drupal_contrib/test_drupal_contrib.info.yml
}

_common_test_php() {
ddev phpcs --version
ddev phpstan --version
ddev phpunit --version
}

_common_test_drupal_version() {
run -0 ddev exec 'drush st --fields=drupal-version --format=string | cut -d. -f1'
[ "$output" = "${TEST_DRUPAL_CORE}" ]
}

_common_test_node() {
ddev exec "cd web/core && yarn install"
ddev exec touch web/core/.env
ddev mutagen sync
ddev stylelint --version
ddev eslint --version
}
6 changes: 1 addition & 5 deletions tests/default-no-composer-json.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ setup_file() {
fi
load '_common.bash'
_common_setup
ddev start
}

teardown_file() {
load '_common.bash'
_common_teardown
}

@test "install from directory" {
load '_common.bash'
_common_test_install
}

@test "ddev poser without composer.json" {
load '_common.bash'
rm -f composer.json
Expand Down
27 changes: 14 additions & 13 deletions tests/full.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,40 @@ setup_file() {
if [ "$TEST_DRUPAL_CORE" = "11" ]; then
ddev config --php-version=8.3 --corepack-enable
fi
ddev start
}

teardown_file() {
load '_common.bash'
_common_teardown
}

@test "install from directory" {
load '_common.bash'
_common_test_install
}

@test "ddev poser with composer.json" {
load '_common.bash'
_common_test_poser
}

@test "ddev symlink-project" {
load '_common.bash'
_common_test_symlink
ddev symlink-project
ddev mutagen sync
ls -la web/modules/custom/test_drupal_contrib/test_drupal_contrib.info.yml
}

@test "php tools availability" {
load '_common.bash'
_common_test_php
ddev phpcs --version
ddev phpstan --version
ddev phpunit --version
}

@test "drupal core version" {
load '_common.bash'
_common_test_drupal_version
run -0 ddev exec 'drush st --fields=drupal-version --format=string | cut -d. -f1'
[ "$output" = "${TEST_DRUPAL_CORE}" ]
}

@test "node tools availability" {
load '_common.bash'
_common_test_node
ddev exec "cd web/core && yarn install"
ddev exec touch web/core/.env
ddev mutagen sync
ddev stylelint --version
ddev eslint --version
}

0 comments on commit 180ae7e

Please sign in to comment.