Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,37 @@ jobs:
run: |
cd drupal-contrib
bats tests

browser-tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
image: ['drupalci/chromedriver:production', 'selenium/standalone-chrome:111.0', 'selenium/standalone-firefox:111.0']

steps:
- name: Create project
run: |
composer create-project --ignore-platform-reqs mstrelan/drupal-contrib:dev-${{ github.ref_name }}

- name: Initialise environment
env:
SELENIUM_IMAGE: ${{ matrix.image }}
MINK_DRIVER_ARGS_WEBDRIVER: ${{ matrix.image == 'drupalci/chromedriver:production' && '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://127.0.0.1:9515"]' || matrix.image == 'selenium/standalone-chrome:111.0' && '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://127.0.0.1:4444/wd/hub"]' || matrix.image == 'selenium/standalone-firefox:111.0' && '["firefox", {"browserName":"firefox"}, "http://127.0.0.1:4444/wd/hub"]' || ''}}
run: |
cd drupal-contrib
make 11.x

- name: Setup homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Setup bats
run: |
brew tap kaos/shell
brew install bats-support bats-assert bats-file

- name: Run tests
run: |
cd drupal-contrib
bats tests/phpunit.bats
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ services:
network_mode: service:nginx

selenium:
image: ${SELENIUM_IMAGE:-selenium/standalone-chrome:111.0}
image: ${SELENIUM_IMAGE:-drupalci/chromedriver:production}
network_mode: service:nginx
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
<env name="MINK_DRIVER_CLASS" value=""/>
<env name="MINK_DRIVER_ARGS" value=""/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome", "goog:chromeOptions":{"args":["--headless", "--no-sandbox", "--disable-dev-shm-usage"], "w3c": false}}, "http://127.0.0.1:4444/wd/hub"]'/>
<env name="MINK_DRIVER_ARGS_WEBDRIVER" value='["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--headless", "--disable-gpu", "--no-sandbox", "--disable-dev-shm-usage"]}}, "http://127.0.0.1:9515"]'/>
</php>
<testsuites>
<testsuite name="unit">
Expand Down
38 changes: 38 additions & 0 deletions tests/phpunit.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
DRUPAL_VERSION="${DRUPAL_VERSION:-9.4}"

setup() {
DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
cd "$DIR/../" || exit
BREW_PREFIX="$(brew --prefix)"
load "${BREW_PREFIX}/lib/bats-assert/load.bash"
}

dce() {
docker compose exec -T php-cli "$@"
}

phpunit() {
dce phpunit "$@"
}

@test "Drupal unit test" {
run phpunit app/core/tests/Drupal/Tests/UnitTestCaseTest.php
assert_success
}

@test "Drupal kernel test" {
run phpunit app/core/tests/Drupal/KernelTests/KernelTestBaseTest.php --filter=testBootEnvironment
assert_success
}

@test "Drupal functional test" {
run phpunit app/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php --filter=testGoTo
assert_success
assert_output --partial "HTML output was generated"
}

@test "Drupal functional javascript test" {
run phpunit app/core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
assert_success
assert_output --partial "HTML output was generated"
}