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
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 && \
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 ./

View file

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

View file

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

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

@ -194,8 +194,11 @@ install_wp_plugins() {
echo "Skipping WordPress plugin installation."
return 0
fi
download https://downloads.wordpress.org/plugin/activitypub.3.2.5.zip $TMPDIR/activitypub.zip
unzip $TMPDIR/activitypub.zip -d $WP_CORE_DIR/wp-content/plugins/
ACTIVITYPUB_FILE="activitypub.3.2.5.zip"
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