diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2c3c7e7..c790f7f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c8194c9..fd66e13 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/phpunit.xml b/phpunit.xml index 9b60293..9ac2f68 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -18,7 +18,7 @@ - + diff --git a/tests/phpunit.bats b/tests/phpunit.bats new file mode 100644 index 0000000..16e5610 --- /dev/null +++ b/tests/phpunit.bats @@ -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" +} \ No newline at end of file