diff --git a/.gitignore b/.gitignore index 7579f74..50b321e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor composer.lock +.phpunit.result.cache diff --git a/Dockerfile b/Dockerfile index 5c4464d..56e97a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 ./ diff --git a/composer.json b/composer.json index 58c647d..df3df13 100644 --- a/composer.json +++ b/composer.json @@ -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" ] } } diff --git a/docker-compose-test.yml b/docker-compose.yml similarity index 52% rename from docker-compose-test.yml rename to docker-compose.yml index 3926e0e..4891aa8 100644 --- a/docker-compose-test.yml +++ b/docker-compose.yml @@ -1,16 +1,19 @@ 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 - retries: 5 + test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"] + start_period: 5s + interval: 4s + timeout: 5s + retries: 5 test-php: build: diff --git a/tests/install-wp-tests.sh b/tests/install-wp-tests.sh old mode 100644 new mode 100755 index f10e7c3..286ea40 --- a/tests/install-wp-tests.sh +++ b/tests/install-wp-tests.sh @@ -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