Skip to content
Merged
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
25 changes: 12 additions & 13 deletions .github/workflows/tests.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ env:
DRUPAL_TESTING_DATABASE_USER: root
DRUPAL_TESTING_DATABASE_PASSWORD: root
DRUPAL_TESTING_DATABASE_ENGINE: mysql
DRUPAL_TESTING_SELENIUM_CHROME_VERSION: '105.0'
DRUPAL_TESTING_SELENIUM_CHROME_VERSION: 'latest'
DRUPAL_TESTING_USE_SELENIUM: 'false'

jobs:
test-projects:
Expand All @@ -24,11 +25,8 @@ jobs:
RUN: [1, 2]
include:
- RUN: 1
DRUPAL_TESTING_DRUPAL_VERSION: '~10.0'
PHP_VERSION: '8.1'
- RUN: 2
DRUPAL_TESTING_DRUPAL_VERSION: '~10.0'
PHP_VERSION: '8.2'
DRUPAL_TESTING_DRUPAL_VERSION: '~11.3'
PHP_VERSION: '8.4'

steps:
- uses: actions/checkout@v1
Expand All @@ -44,7 +42,7 @@ jobs:
sudo /etc/init.d/mysql start

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }}
Expand Down Expand Up @@ -74,23 +72,23 @@ jobs:
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.1'
php-version: '8.3'
extensions: gd, pdo_mysql

- name: Start MySql service
run: |
sudo /etc/init.d/mysql start

- name: Cache composer dependencies
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-cache-

- name: Cache NPM dependencies
id: npm-cache
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache
Expand All @@ -110,7 +108,7 @@ jobs:
run: cd /tmp; tar cfz build.tgz test; mv build.tgz ${GITHUB_WORKSPACE}

- name: Upload build
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: build
path: build.tgz
Expand All @@ -126,7 +124,7 @@ jobs:
- uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: '8.1'
php-version: '8.3'
extensions: gd, pdo_mysql

- name: Start MySql service
Expand All @@ -139,9 +137,10 @@ jobs:
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH

- name: Download build
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: build
path: build

- name: Unzip build artifact
run: tar xCfz /tmp build/build.tgz test; rm -rf build
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
],
"require": {
"php": ">=7.2",
"drupal/coder": "^8.3",
"symfony/yaml": "^3.4"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the yaml dependency?

"drupal/coder": "^8.3"
},
"config": {
"allow-plugins": {
Expand Down
5 changes: 3 additions & 2 deletions configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ DRUPAL_TESTING_COMPOSER_PROJECT=${DRUPAL_TESTING_COMPOSER_PROJECT:-"drupal/recom

# The drupal version to test against. This can be any valid composer version string, but only drupal versions greater 8.6
# are supported. By default, we use the most recent stable version.
DRUPAL_TESTING_DRUPAL_VERSION=${DRUPAL_TESTING_DRUPAL_VERSION:-$(git ls-remote --tags --sort=-version:refname https://github.com/drupal/core.git | grep -E -o '[0-9]+\.[0-9]\.[0-9]+$' | head -n1)}
_drupal_latest_core=$(git ls-remote --tags --sort=-version:refname https://github.com/drupal/core.git | grep -E -o '[0-9]+\.[0-9]+\.[0-9]+$' | head -n1)
DRUPAL_TESTING_DRUPAL_VERSION=${DRUPAL_TESTING_DRUPAL_VERSION:-"~${_drupal_latest_core%.*}"}

# The version of the composer project to use.
DRUPAL_TESTING_COMPOSER_PROJECT_VERSION=${DRUPAL_TESTING_COMPOSER_PROJECT_VERSION:-${DRUPAL_TESTING_DRUPAL_VERSION}}
Expand Down Expand Up @@ -190,7 +191,7 @@ export SYMFONY_DEPRECATIONS_HELPER=${SYMFONY_DEPRECATIONS_HELPER-weak}
export SIMPLETEST_BASE_URL=${SIMPLETEST_BASE_URL:-http://${DRUPAL_TESTING_HTTP_HOST}:${DRUPAL_TESTING_HTTP_PORT}}

# The driver args for webdriver.
export MINK_DRIVER_ARGS_WEBDRIVER=${MINK_DRIVER_ARGS_WEBDRIVER-"[\"chrome\", {\"chromeOptions\": {\"w3c\": false } }, \"http://${DRUPAL_TESTING_SELENIUM_HOST}:${DRUPAL_TESTING_SELENIUM_PORT}/wd/hub\"]"}
export MINK_DRIVER_ARGS_WEBDRIVER=${MINK_DRIVER_ARGS_WEBDRIVER-"[\"chrome\", {\"goog:chromeOptions\": {\"args\": [\"--headless\", \"--disable-gpu\", \"--no-sandbox\", \"--disable-dev-shm-usage\"]}}, \"http://${DRUPAL_TESTING_SELENIUM_HOST}:${DRUPAL_TESTING_SELENIUM_PORT}/wd/hub\"]"}

# Increase composer memory limit.
export COMPOSER_MEMORY_LIMIT=${COMPOSER_MEMORY_LIMIT:-"-1"}
Expand Down
4 changes: 3 additions & 1 deletion lib/stages/prepare_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ _stage_prepare_build() {
# Build is based on drupal project
composer create-project "${DRUPAL_TESTING_COMPOSER_PROJECT}":"${DRUPAL_TESTING_COMPOSER_PROJECT_VERSION}" "${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}" --no-interaction --no-install

# Disable blocking on security advisories — this is a CI test environment, not production.
composer config audit.block-insecure false --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
composer config "prefer-stable" true --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"

if [[ ${DRUPAL_TESTING_PROJECT_TYPE} != "drupal-profile" ]]; then
Expand Down Expand Up @@ -61,7 +63,7 @@ _stage_prepare_build() {
composer config extra.enable-patching true --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"

# Use jq to find all dev dependencies of the project and add them to root composer file.
for dev_dependency in $(jq -r '.["require-dev"?] | keys[] as $k | "\($k):\(.[$k])"' "${DRUPAL_TESTING_PROJECT_BASEDIR}"/composer.json); do
for dev_dependency in $(jq -r '(.["require-dev"?] // {}) | keys[] as $k | "\($k):\(.[$k])"' "${DRUPAL_TESTING_PROJECT_BASEDIR}"/composer.json); do
composer require "${dev_dependency}" --dev --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
done

Expand Down
2 changes: 2 additions & 0 deletions lib/stages/prepare_old_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ _stage_prepare_old_install() {
# Build is based on drupal project
composer create-project "${DRUPAL_TESTING_COMPOSER_PROJECT}":"${DRUPAL_TESTING_UPGRADE_COMPOSER_PROJECT_VERSION}" "${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}" --no-interaction --no-install

# Disable blocking on security advisories — this is a CI test environment, not production.
composer config audit.block-insecure false --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
composer config "prefer-stable" true --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"

# Reorder repositories, to make sure, local path is first.
Expand Down
2 changes: 1 addition & 1 deletion lib/stages/prepare_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ _stage_prepare_upgrade() {
# Set the path repository back to the project under test.
composer config repositories.0 --json "{\"type\":\"path\", \"url\":\"${DRUPAL_TESTING_PROJECT_BASEDIR}\", \"options\":{\"symlink\": false}}" --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
# Use jq to find all dev dependencies of the project and add them to root composer file.
for dev_dependency in $(jq -r '.["require-dev"?] | keys[] as $k | "\($k):\(.[$k])"' "${DRUPAL_TESTING_PROJECT_BASEDIR}"/composer.json); do
for dev_dependency in $(jq -r '(.["require-dev"?] // {}) | keys[] as $k | "\($k):\(.[$k])"' "${DRUPAL_TESTING_PROJECT_BASEDIR}"/composer.json); do
composer require "${dev_dependency}" --dev --no-update --working-dir="${DRUPAL_TESTING_DRUPAL_INSTALLATION_DIRECTORY}"
done

Expand Down
19 changes: 17 additions & 2 deletions lib/stages/start_services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,27 @@ _stage_start_services() {

if [ "${DRUPAL_TESTING_USE_SELENIUM}" = true ]; then
docker run --detach --net host --name "${DRUPAL_TESTING_SELENIUM_DOCKER_NAME}" --volume "${DRUPAL_TESTING_PROJECT_BASEDIR}":/project --volume /dev/shm:/dev/shm selenium/standalone-chrome:"${DRUPAL_TESTING_SELENIUM_CHROME_VERSION}"
wait_for_port "${DRUPAL_TESTING_SELENIUM_HOST}" "${DRUPAL_TESTING_SELENIUM_PORT}"
# Wait for Selenium node to register — port open ≠ Chrome node ready.
local selenium_status_url="http://${DRUPAL_TESTING_SELENIUM_HOST}:${DRUPAL_TESTING_SELENIUM_PORT}/status"
local ready_count=0
until curl -sf "${selenium_status_url}" | grep -q '"ready":true'; do
sleep 2
ready_count=$((ready_count + 1))
if [[ ${ready_count} -gt 15 ]]; then
printf "Error: Selenium node did not become ready in time.\n" 1>&2
exit 1
fi
done
elif command -v chromedriver > /dev/null 2>&1; then
# Use system ChromeDriver (pre-installed on GitHub Actions runners).
chromedriver --port="${DRUPAL_TESTING_SELENIUM_PORT}" --url-base=/wd/hub &
wait_for_port "${DRUPAL_TESTING_SELENIUM_HOST}" "${DRUPAL_TESTING_SELENIUM_PORT}"
else
download_chromedriver
"${DRUPAL_TESTING_TEST_BASE_DIRECTORY}"/chromedriver --port="${DRUPAL_TESTING_SELENIUM_PORT}" --url-base=/wd/hub &
wait_for_port "${DRUPAL_TESTING_SELENIUM_HOST}" "${DRUPAL_TESTING_SELENIUM_PORT}"
fi

wait_for_port "${DRUPAL_TESTING_SELENIUM_HOST}" "${DRUPAL_TESTING_SELENIUM_PORT}"
fi

if ! port_is_open "${DRUPAL_TESTING_HTTP_HOST}" "${DRUPAL_TESTING_HTTP_PORT}"; then
Expand Down
2 changes: 1 addition & 1 deletion tests/module/module.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ name: Module
type: module
description: Drupal module with all sorts of tests, to test capabilities of the drupal-testing package.
package: Drupal Testing
core_version_requirement: ^9 || ^10
core_version_requirement: ^9 || ^10 || ^11
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
namespace Drupal\Tests\module\FunctionalJavascript;

use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;

/**
* Class ModuleControllerTest.
*
* Javascript tests.
*
* @group module
*/
#[Group('module')]
#[RunTestsInSeparateProcesses]
class ModuleControllerTest extends WebDriverTestBase {

/**
Expand Down
15 changes: 9 additions & 6 deletions tests/module/tests/Unit/ModuleServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@

use Drupal\module\Service;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;

/**
* @coversDefaultClass \Drupal\module\Service
* @group module
* Tests for the Service class.
*/
#[CoversClass(\Drupal\module\Service::class)]
#[Group('module')]
class ModuleServiceTest extends UnitTestCase {
/**
* The entity permission provider.
Expand All @@ -27,10 +31,9 @@ protected function setUp(): void {
}

/**
* @covers ::serve
*
* @dataProvider numberProvider
* Tests the serve method.
*/
#[DataProvider('numberProvider')]
public function testServe($number, $serving): void {
$this->assertEquals($serving, $this->service->serve($number));
}
Expand All @@ -41,7 +44,7 @@ public function testServe($number, $serving): void {
* @return array
* A list of number and the servings they generate.
*/
public function numberProvider(): array {
public static function numberProvider(): array {
return [
[1, 'You have been served a 1'],
];
Expand Down
Loading