fix docker compose file for running unit tests locally
All checks were successful
PHP Code Checker / PHP Code Checker (push) Successful in 33s
PHPUnit / PHPUnit – PHP 8.1 (push) Successful in 1m1s
PHPUnit / PHPUnit – PHP 8.2 (push) Successful in 56s
PHPUnit / PHPUnit – PHP 8.3 (push) Successful in 56s

This commit is contained in:
André Menrath 2024-09-21 14:59:26 +02:00
parent c495e65105
commit 6edc402581
5 changed files with 25 additions and 13 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
vendor vendor
composer.lock composer.lock
.phpunit.result.cache

View file

@ -24,4 +24,9 @@ RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli
chmod +x wp-cli.phar && \ chmod +x wp-cli.phar && \
mv wp-cli.phar /usr/local/bin/wp mv wp-cli.phar /usr/local/bin/wp
COPY composer.json composer.lock /app/
RUN composer install --no-scripts --no-autoloader
RUN composer global require yoast/phpunit-polyfills:"^3.0" --dev
ENV PATH="/root/.composer/vendor/bin:${PATH}"
RUN chmod +x -R ./ RUN chmod +x -R ./

View file

@ -3,8 +3,8 @@
"description": "The ActivityPub Event Extensions help for event custom post types to federate properly.", "description": "The ActivityPub Event Extensions help for event custom post types to federate properly.",
"type": "wordpress-plugin", "type": "wordpress-plugin",
"require": { "require": {
"php": ">=5.6.0", "php": ">=8.1.0",
"composer/installers": "^1.0 || ^2.0" "composer/installers": "^2.0"
}, },
"require-dev": { "require-dev": {
"phpcompatibility/php-compatibility": "*", "phpcompatibility/php-compatibility": "*",
@ -39,8 +39,8 @@
], ],
"test": [ "test": [
"composer install", "composer install",
"tests/install-wp-tests.sh activitypub-test root activitypub-test test-db latest true", "tests/install-wp-tests.sh wordpress-test root wordpress-test test-db latest true",
"vendor/bin/phpunit" "phpunit"
] ]
} }
} }

View file

@ -1,16 +1,19 @@
version: '3' version: '3'
# This files purpose is to run the PHPunit tests locally.
services: services:
test-db: test-db:
platform: linux/x86_64
image: mariadb image: mariadb
environment: environment:
MYSQL_DATABASE: wordpress MARIADB_DATABASE: wordpress-test
MYSQL_ROOT_PASSWORD: wordpress MARIADB_ROOT_PASSWORD: wordpress-test
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3306"] test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 5s start_period: 5s
timeout: 2s interval: 4s
retries: 5 timeout: 5s
retries: 5
test-php: test-php:
build: build:

7
tests/install-wp-tests.sh Normal file → Executable file
View file

@ -194,8 +194,11 @@ install_wp_plugins() {
echo "Skipping WordPress plugin installation." echo "Skipping WordPress plugin installation."
return 0 return 0
fi fi
download https://downloads.wordpress.org/plugin/activitypub.3.2.5.zip $TMPDIR/activitypub.zip ACTIVITYPUB_FILE="activitypub.3.2.5.zip"
unzip $TMPDIR/activitypub.zip -d $WP_CORE_DIR/wp-content/plugins/ if ! test -f $TMPDIR/$ACTIVITYPUB_FILE; then
download https://downloads.wordpress.org/plugin/$ACTIVITYPUB_FILE $TMPDIR/$ACTIVITYPUB_FILE
fi
unzip -o $TMPDIR/$ACTIVITYPUB_FILE -d $WP_CORE_DIR/wp-content/plugins/
} }
install_wp install_wp