From 161e4fced4518f06cb003e49ace5fc89230dd1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 19:22:25 +0200 Subject: [PATCH 01/50] test --- .forgejo/workflows/phpunit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 6df0ddf..d41724b 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -12,7 +12,6 @@ jobs: MYSQL_ROOT_PASSWORD: root ports: - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10 strategy: matrix: php-versions: ['8.1', '8.2', '8.3'] -- 2.39.5 From b0f01cfaf50b64eab6d27a392761510e0cf3502c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:18:57 +0200 Subject: [PATCH 02/50] fix test --- phpunit.xml.dist | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..50421ec --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + ./tests/ + ./tests/test-sample.php + + + -- 2.39.5 From 626c4d5ffc1dd44a95f3b3aff2fe15fc6f1e35b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:20:06 +0200 Subject: [PATCH 03/50] test runner --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index d41724b..fb53a2c 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest services: mysql: - image: mariadb:11.5 + image: 'mariadb:10.7' env: MYSQL_ROOT_PASSWORD: root ports: -- 2.39.5 From 92321bb9f0990b41680db622f7e7b3b2e6d960f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:28:22 +0200 Subject: [PATCH 04/50] fix phpunit test --- .forgejo/workflows/phpunit.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index fb53a2c..2b4911a 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -12,11 +12,11 @@ jobs: MYSQL_ROOT_PASSWORD: root ports: - 3306:3306 - strategy: - matrix: - php-versions: ['8.1', '8.2', '8.3'] - include: - - wp-version: latest + strategy: + matrix: + php-versions: ['8.1', '8.2', '8.3'] + include: + - wp-version: latest steps: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 -- 2.39.5 From 20a05678ba1533b38d8e4fbacc8d233acc7762f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:29:31 +0200 Subject: [PATCH 05/50] test phpunit workflow --- .forgejo/workflows/phpunit.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 2b4911a..96cae36 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -21,13 +21,13 @@ jobs: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 - # - name: Setup PHP - # uses: shivammathur/setup-php@v2 - # with: - # php-version: ${{ matrix.php-versions }} - # coverage: none - # tools: composer, phpunit-polyfills - # extensions: mysql + - name: Setup PHP + uses: https://github.com/shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + tools: composer, phpunit-polyfills + extensions: mysql # - name: Install Composer dependencies for PHP # uses: "ramsey/composer-install@v1" -- 2.39.5 From 3d689713ad6603c8b4205ea5d75be8b04623a3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:34:47 +0200 Subject: [PATCH 06/50] add more test files --- .forgejo/workflows/tests.yml | 114 ++++++++++++++++++++++ .phpcs.xml.dist | 47 +++++++++ bin/install-wp-tests.sh | 181 +++++++++++++++++++++++++++++++++++ docker-compose-test.yml | 26 +++++ tests/bootstrap.php | 38 ++++++++ tests/test-sample.php | 20 ++++ 6 files changed, 426 insertions(+) create mode 100755 .forgejo/workflows/tests.yml create mode 100644 .phpcs.xml.dist create mode 100755 bin/install-wp-tests.sh create mode 100644 docker-compose-test.yml create mode 100755 tests/bootstrap.php create mode 100755 tests/test-sample.php diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml new file mode 100755 index 0000000..899bae0 --- /dev/null +++ b/.forgejo/workflows/tests.yml @@ -0,0 +1,114 @@ +workflows: + version: 2 + main: + jobs: + - php56-build + - php70-build + - php71-build + - php72-build + - php73-build + - php74-build + +version: 2 + +job-references: + mysql_image: &mysql_image + circleci/mysql:5.6 + + setup_environment: &setup_environment + name: "Setup Environment Variables" + command: | + echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV + source /home/circleci/.bashrc + + install_dependencies: &install_dependencies + name: "Install Dependencies" + command: | + sudo apt-get update && sudo apt-get install subversion + sudo -E docker-php-ext-install mysqli + sudo sh -c "printf '\ndeb http://ftp.us.debian.org/debian sid main\n' >> /etc/apt/sources.list" + sudo apt-get update && sudo apt-get install mysql-client-5.7 + + php_job: &php_job + environment: + - WP_TESTS_DIR: "/tmp/wordpress-tests-lib" + - WP_CORE_DIR: "/tmp/wordpress/" + steps: + - checkout + - run: *setup_environment + - run: *install_dependencies + - run: + name: "Run Tests" + command: | + composer global require "phpunit/phpunit=5.7.*" + composer global require wp-coding-standards/wpcs + phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs + phpcs + rm -rf $WP_TESTS_DIR $WP_CORE_DIR + bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest + phpunit + WP_MULTISITE=1 phpunit + +jobs: + php56-build: + <<: *php_job + docker: + - image: circleci/php:5.6 + - image: *mysql_image + steps: + - checkout + - run: *setup_environment + - run: *install_dependencies + - run: + name: "Run Tests" + command: | + composer global require "phpunit/phpunit=5.7.*" + composer global require wp-coding-standards/wpcs + phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs + phpcs + SKIP_DB_CREATE=false + rm -rf $WP_TESTS_DIR $WP_CORE_DIR + bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 5.5 $SKIP_DB_CREATE + phpunit + WP_MULTISITE=1 phpunit + SKIP_DB_CREATE=true + rm -rf $WP_TESTS_DIR $WP_CORE_DIR + bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest $SKIP_DB_CREATE + phpunit + WP_MULTISITE=1 phpunit + SKIP_DB_CREATE=true + rm -rf $WP_TESTS_DIR $WP_CORE_DIR + bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 trunk $SKIP_DB_CREATE + phpunit + WP_MULTISITE=1 phpunit + SKIP_DB_CREATE=true + + php70-build: + <<: *php_job + docker: + - image: circleci/php:7.0 + - image: *mysql_image + + php71-build: + <<: *php_job + docker: + - image: circleci/php:7.1 + - image: *mysql_image + + php72-build: + <<: *php_job + docker: + - image: circleci/php:7.2 + - image: *mysql_image + + php73-build: + <<: *php_job + docker: + - image: circleci/php:7.3 + - image: *mysql_image + + php74-build: + <<: *php_job + docker: + - image: circleci/php:7.4 + - image: *mysql_image diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist new file mode 100644 index 0000000..df58068 --- /dev/null +++ b/.phpcs.xml.dist @@ -0,0 +1,47 @@ + + + Generally-applicable sniffs for WordPress plugins. + + + . + /vendor/ + /node_modules/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh new file mode 100755 index 0000000..c6f53dc --- /dev/null +++ b/bin/install-wp-tests.sh @@ -0,0 +1,181 @@ +#!/usr/bin/env bash + +if [ $# -lt 3 ]; then + echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" + exit 1 +fi + +DB_NAME=$1 +DB_USER=$2 +DB_PASS=$3 +DB_HOST=${4-localhost} +WP_VERSION=${5-latest} +SKIP_DB_CREATE=${6-false} + +TMPDIR=${TMPDIR-/tmp} +TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") +WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} +WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress} + +download() { + if [ `which curl` ]; then + curl -s "$1" > "$2"; + elif [ `which wget` ]; then + wget -nv -O "$2" "$1" + fi +} + +if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\-(beta|RC)[0-9]+$ ]]; then + WP_BRANCH=${WP_VERSION%\-*} + WP_TESTS_TAG="branches/$WP_BRANCH" + +elif [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then + WP_TESTS_TAG="branches/$WP_VERSION" +elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then + if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then + # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x + WP_TESTS_TAG="tags/${WP_VERSION%??}" + else + WP_TESTS_TAG="tags/$WP_VERSION" + fi +elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then + WP_TESTS_TAG="trunk" +else + # http serves a single offer, whereas https serves multiple. we only want one + download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json + grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json + LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') + if [[ -z "$LATEST_VERSION" ]]; then + echo "Latest WordPress version could not be found" + exit 1 + fi + WP_TESTS_TAG="tags/$LATEST_VERSION" +fi +set -ex + +install_wp() { + + if [ -d $WP_CORE_DIR ]; then + return; + fi + + mkdir -p $WP_CORE_DIR + + if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then + mkdir -p $TMPDIR/wordpress-trunk + rm -rf $TMPDIR/wordpress-trunk/* + svn export --quiet https://core.svn.wordpress.org/trunk $TMPDIR/wordpress-trunk/wordpress + mv $TMPDIR/wordpress-trunk/wordpress/* $WP_CORE_DIR + else + if [ $WP_VERSION == 'latest' ]; then + local ARCHIVE_NAME='latest' + elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then + # https serves multiple offers, whereas http serves single. + download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json + if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then + # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x + LATEST_VERSION=${WP_VERSION%??} + else + # otherwise, scan the releases and get the most up to date minor version of the major release + local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` + LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1) + fi + if [[ -z "$LATEST_VERSION" ]]; then + local ARCHIVE_NAME="wordpress-$WP_VERSION" + else + local ARCHIVE_NAME="wordpress-$LATEST_VERSION" + fi + else + local ARCHIVE_NAME="wordpress-$WP_VERSION" + fi + download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz + tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR + fi + + download https://raw.githubusercontent.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php +} + +install_test_suite() { + # portable in-place argument for both GNU sed and Mac OSX sed + if [[ $(uname -s) == 'Darwin' ]]; then + local ioption='-i.bak' + else + local ioption='-i' + fi + + # set up testing suite if it doesn't yet exist + if [ ! -d $WP_TESTS_DIR ]; then + # set up testing suite + mkdir -p $WP_TESTS_DIR + rm -rf $WP_TESTS_DIR/{includes,data} + svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes + svn export --quiet --ignore-externals https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data + fi + + if [ ! -f wp-tests-config.php ]; then + download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php + # remove all forward slashes in the end + WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") + sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s:__DIR__ . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php + fi + +} + +recreate_db() { + shopt -s nocasematch + if [[ $1 =~ ^(y|yes)$ ]] + then + mysqladmin drop $DB_NAME -f --user="$DB_USER" --password="$DB_PASS"$EXTRA + create_db + echo "Recreated the database ($DB_NAME)." + else + echo "Leaving the existing database ($DB_NAME) in place." + fi + shopt -u nocasematch +} + +create_db() { + mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA +} + +install_db() { + + if [ ${SKIP_DB_CREATE} = "true" ]; then + return 0 + fi + + # parse DB_HOST for port or socket references + local PARTS=(${DB_HOST//\:/ }) + local DB_HOSTNAME=${PARTS[0]}; + local DB_SOCK_OR_PORT=${PARTS[1]}; + local EXTRA="" + + if ! [ -z $DB_HOSTNAME ] ; then + if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then + EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" + elif ! [ -z $DB_SOCK_OR_PORT ] ; then + EXTRA=" --socket=$DB_SOCK_OR_PORT" + elif ! [ -z $DB_HOSTNAME ] ; then + EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" + fi + fi + + # create database + if [ $(mysql --user="$DB_USER" --password="$DB_PASS"$EXTRA --execute='show databases;' | grep ^$DB_NAME$) ] + then + echo "Reinstalling will delete the existing test database ($DB_NAME)" + read -p 'Are you sure you want to proceed? [y/N]: ' DELETE_EXISTING_DB + recreate_db $DELETE_EXISTING_DB + else + create_db + fi +} + +install_wp +install_test_suite +install_db diff --git a/docker-compose-test.yml b/docker-compose-test.yml new file mode 100644 index 0000000..3926e0e --- /dev/null +++ b/docker-compose-test.yml @@ -0,0 +1,26 @@ +version: '3' +services: + test-db: + platform: linux/x86_64 + image: mariadb + environment: + MYSQL_DATABASE: wordpress + MYSQL_ROOT_PASSWORD: wordpress + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3306"] + interval: 5s + timeout: 2s + retries: 5 + + test-php: + build: + context: . + dockerfile: Dockerfile + depends_on: + test-db: + condition: service_healthy + links: + - test-db + volumes: + - .:/app + command: ["composer", "run-script", "test"] diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100755 index 0000000..72f381a --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,38 @@ +assertTrue( true ); + } +} -- 2.39.5 From 4ed94f5d602b1dbd376fdacaed3adbd5acee0a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:35:00 +0200 Subject: [PATCH 07/50] update phpunit workflow --- .forgejo/workflows/phpunit.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 96cae36..f670987 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -29,13 +29,13 @@ jobs: tools: composer, phpunit-polyfills extensions: mysql - # - name: Install Composer dependencies for PHP - # uses: "ramsey/composer-install@v1" + - name: Install Composer dependencies for PHP + uses: "ramsey/composer-install@v1" - # - name: Setup Test Environment - # run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} + - name: Setup Test Environment + run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} - # - name: Unit Testing - # run: ./vendor/bin/phpunit - # env: - # PHP_VERSION: ${{ matrix.php-versions }} + - name: Unit Testing + run: ./vendor/bin/phpunit + env: + PHP_VERSION: ${{ matrix.php-versions }} -- 2.39.5 From 543f8a38f6ebadfc5186e59537fc4a09b773c609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:35:52 +0200 Subject: [PATCH 08/50] only test php 8.1 for now --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index f670987..005a42c 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -14,7 +14,7 @@ jobs: - 3306:3306 strategy: matrix: - php-versions: ['8.1', '8.2', '8.3'] + php-versions: ['8.1'] include: - wp-version: latest steps: -- 2.39.5 From a8f06441bd685034e2080876685d9faa02995a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:36:39 +0200 Subject: [PATCH 09/50] update workflow --- .forgejo/workflows/phpunit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 005a42c..083f2b5 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -1,6 +1,8 @@ name: Unit Testing on: push: + branches: + - main pull_request: jobs: phpunit: -- 2.39.5 From 658bd62af02d0ff56998a7bb0341a0f907af63e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:51:02 +0200 Subject: [PATCH 10/50] test --- .forgejo/workflows/phpunit.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 083f2b5..e33d9cd 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -34,6 +34,9 @@ jobs: - name: Install Composer dependencies for PHP uses: "ramsey/composer-install@v1" + - name: Install mysqladmin + run: apt install mysql-client-core + - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} -- 2.39.5 From 69108e3f260ca1d38e1750efeefbf627e4b93747 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 20:58:46 +0200 Subject: [PATCH 11/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index e33d9cd..a461070 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -35,7 +35,7 @@ jobs: uses: "ramsey/composer-install@v1" - name: Install mysqladmin - run: apt install mysql-client-core + run: apt update && apt-get -y install mysql-client-core - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} -- 2.39.5 From 4aaa8d87cdda08e3185993d6287a2bf599a46148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:03:22 +0200 Subject: [PATCH 12/50] test --- .forgejo/workflows/phpunit.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index a461070..cca8b72 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -19,17 +19,35 @@ jobs: php-versions: ['8.1'] include: - wp-version: latest + name: Run phpunit tests + env: + extensions: mysql + key: cache-v1 steps: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 + - name: Setup cache environment + id: extensioncache + uses: https://github.com/shivammathur/cache-extensions@v1 + with: + php-version: ${{ matrix.php-versions }} + extensions: ${{ env.extensions }} + key: ${{ env.key }} + + - name: Cache extensions + uses: https://code.forgejo.org/actions/cache@v4 + with: + path: ${{ steps.extensioncache.outputs.dir }} + key: ${{ steps.extensioncache.outputs.key }} + restore-keys: ${{ steps.extensioncache.outputs.key }} + - name: Setup PHP uses: https://github.com/shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} coverage: none tools: composer, phpunit-polyfills - extensions: mysql - name: Install Composer dependencies for PHP uses: "ramsey/composer-install@v1" -- 2.39.5 From 9230f40f13fef638c00e8a8e881a4fe6ba0fa58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:08:12 +0200 Subject: [PATCH 13/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index cca8b72..b438090 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -53,7 +53,7 @@ jobs: uses: "ramsey/composer-install@v1" - name: Install mysqladmin - run: apt update && apt-get -y install mysql-client-core + run: sudo apt-get update && sudo apt-get -y install mysql-client-core - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} -- 2.39.5 From 15b678243d17f054a1db0362fced8f971f3cc107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:09:16 +0200 Subject: [PATCH 14/50] test --- .forgejo/workflows/phpunit.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index b438090..1297039 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -17,8 +17,7 @@ jobs: strategy: matrix: php-versions: ['8.1'] - include: - - wp-version: latest + wp-version: [latest] name: Run phpunit tests env: extensions: mysql -- 2.39.5 From 65bdac1b712d5ee5dd4a5b7bd0a229ce2e9d43f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:27:40 +0200 Subject: [PATCH 15/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 1297039..b15444a 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -52,7 +52,7 @@ jobs: uses: "ramsey/composer-install@v1" - name: Install mysqladmin - run: sudo apt-get update && sudo apt-get -y install mysql-client-core + run: sudo apt update && sudo apt -y install mysql-client - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} -- 2.39.5 From 20d965ba279f6ae93e2db825c13e439f3eefa51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:30:10 +0200 Subject: [PATCH 16/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index b15444a..ccf8899 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -52,7 +52,7 @@ jobs: uses: "ramsey/composer-install@v1" - name: Install mysqladmin - run: sudo apt update && sudo apt -y install mysql-client + run: sudo apt update && sudo apt upgrade && sudo apt -y install mysql-client - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} -- 2.39.5 From b478bb51a45b46e8c858702d8c9a65d58f65124f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:32:12 +0200 Subject: [PATCH 17/50] test --- .forgejo/workflows/phpunit.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index ccf8899..421ce49 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -26,20 +26,20 @@ jobs: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 - - name: Setup cache environment - id: extensioncache - uses: https://github.com/shivammathur/cache-extensions@v1 - with: - php-version: ${{ matrix.php-versions }} - extensions: ${{ env.extensions }} - key: ${{ env.key }} + # - name: Setup cache environment + # id: extensioncache + # uses: https://github.com/shivammathur/cache-extensions@v1 + # with: + # php-version: ${{ matrix.php-versions }} + # extensions: ${{ env.extensions }} + # key: ${{ env.key }} - - name: Cache extensions - uses: https://code.forgejo.org/actions/cache@v4 - with: - path: ${{ steps.extensioncache.outputs.dir }} - key: ${{ steps.extensioncache.outputs.key }} - restore-keys: ${{ steps.extensioncache.outputs.key }} + # - name: Cache extensions + # uses: https://code.forgejo.org/actions/cache@v4 + # with: + # path: ${{ steps.extensioncache.outputs.dir }} + # key: ${{ steps.extensioncache.outputs.key }} + # restore-keys: ${{ steps.extensioncache.outputs.key }} - name: Setup PHP uses: https://github.com/shivammathur/setup-php@v2 -- 2.39.5 From 8834129a0bd8c0b172f4bdeafd06b4785569db8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:42:21 +0200 Subject: [PATCH 18/50] test --- .forgejo/workflows/phpunit.yml | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 421ce49..9028e82 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -26,20 +26,12 @@ jobs: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 - # - name: Setup cache environment - # id: extensioncache - # uses: https://github.com/shivammathur/cache-extensions@v1 - # with: - # php-version: ${{ matrix.php-versions }} - # extensions: ${{ env.extensions }} - # key: ${{ env.key }} - - # - name: Cache extensions - # uses: https://code.forgejo.org/actions/cache@v4 - # with: - # path: ${{ steps.extensioncache.outputs.dir }} - # key: ${{ steps.extensioncache.outputs.key }} - # restore-keys: ${{ steps.extensioncache.outputs.key }} + - name: Cache composer dependencies + id: cache-primes + uses: actions/cache@v4 + with: + path: /root/.cache/composer + key: cache-1 - name: Setup PHP uses: https://github.com/shivammathur/setup-php@v2 @@ -52,7 +44,7 @@ jobs: uses: "ramsey/composer-install@v1" - name: Install mysqladmin - run: sudo apt update && sudo apt upgrade && sudo apt -y install mysql-client + run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} -- 2.39.5 From eb16b3173eadfbd5939a6a4b72777f0a0a10ed39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 21:55:36 +0200 Subject: [PATCH 19/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 9028e82..d6a739d 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -47,7 +47,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp-version }} + run: bash bin/install-wp-tests.sh wordpress_test root root mysql ${{ matrix.wp-version }} - name: Unit Testing run: ./vendor/bin/phpunit -- 2.39.5 From 5d8915abcc7ac8e7139f7707f8f7e5824480e3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 22:12:42 +0200 Subject: [PATCH 20/50] test --- .forgejo/workflows/phpunit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index d6a739d..2f24bea 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest services: mysql: - image: 'mariadb:10.7' + image: mariadb env: MYSQL_ROOT_PASSWORD: root ports: @@ -47,7 +47,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root mysql ${{ matrix.wp-version }} + run: bash bin/install-wp-tests.sh wordpress_test root root http://mysql:3306 ${{ matrix.wp-version }} - name: Unit Testing run: ./vendor/bin/phpunit -- 2.39.5 From 3313dfc7f39a7ce27198bf24a05f0445732c6b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 22:25:41 +0200 Subject: [PATCH 21/50] test --- .forgejo/workflows/phpunit.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 2f24bea..e15e351 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -26,12 +26,12 @@ jobs: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 - - name: Cache composer dependencies - id: cache-primes - uses: actions/cache@v4 - with: - path: /root/.cache/composer - key: cache-1 + # - name: Cache composer dependencies + # id: cache-primes + # uses: actions/cache@v4 + # with: + # path: /root/.cache/composer + # key: cache-1 - name: Setup PHP uses: https://github.com/shivammathur/setup-php@v2 @@ -47,7 +47,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root http://mysql:3306 ${{ matrix.wp-version }} + run: bash bin/install-wp-tests.sh wordpress_test root root 'http://mysql:3306' ${{ matrix.wp-version }} - name: Unit Testing run: ./vendor/bin/phpunit -- 2.39.5 From 34d896d40dd310948a9bf3c20c6992c790f8007f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 22:38:41 +0200 Subject: [PATCH 22/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index e15e351..6e128d2 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -47,7 +47,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root 'http://mysql:3306' ${{ matrix.wp-version }} + run: bash bin/install-wp-tests.sh wordpress_test root root mysql:3306 ${{ matrix.wp-version }} - name: Unit Testing run: ./vendor/bin/phpunit -- 2.39.5 From c0dc94844a7b95621c964d456da71373b289647f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Fri, 20 Sep 2024 22:52:14 +0200 Subject: [PATCH 23/50] test --- .forgejo/workflows/phpunit.yml | 5 +---- .woodpecker/test.yml | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 .woodpecker/test.yml diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 6e128d2..283d093 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -12,12 +12,9 @@ jobs: image: mariadb env: MYSQL_ROOT_PASSWORD: root - ports: - - 3306:3306 strategy: matrix: php-versions: ['8.1'] - wp-version: [latest] name: Run phpunit tests env: extensions: mysql @@ -47,7 +44,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root mysql:3306 ${{ matrix.wp-version }} + run: bash bin/install-wp-tests.sh wordpress_test root root mysql latest - name: Unit Testing run: ./vendor/bin/phpunit diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml new file mode 100644 index 0000000..fe28da6 --- /dev/null +++ b/.woodpecker/test.yml @@ -0,0 +1,19 @@ +when: + - event: push + branch: woodpecker + +steps: + - name: build + image: php:8.3 + environment: + WP_TESTS_PHPUNIT_POLYFILLS_PATH: vendor/yoast/phpunit-polyfills + commands: + - apt -y update + - apt -y install libonig-dev + - docker-php-ext-install mbstring mysqli pdo_mysql intl gd zip bz2 + - docker-php-ext-enable mbstring mysqli pdo_mysql intl gd zip bz2 + - composer require --dev yoast/phpunit-polyfills:"^3.0" + - composer install + - bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true + - phpunit --configuration phpunit.xml.dist + -- 2.39.5 From 658b65adf1c5602b9c4e56ccb5a696b67e762aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 00:32:12 +0200 Subject: [PATCH 24/50] test --- .forgejo/workflows/phpunit.yml | 2 +- .forgejo/workflows/tests.yml | 114 --------------------------------- 2 files changed, 1 insertion(+), 115 deletions(-) delete mode 100755 .forgejo/workflows/tests.yml diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 283d093..05e47b8 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -44,7 +44,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root mysql latest + run: bash bin/install-wp-tests.sh wordpress_test root root localhost latest - name: Unit Testing run: ./vendor/bin/phpunit diff --git a/.forgejo/workflows/tests.yml b/.forgejo/workflows/tests.yml deleted file mode 100755 index 899bae0..0000000 --- a/.forgejo/workflows/tests.yml +++ /dev/null @@ -1,114 +0,0 @@ -workflows: - version: 2 - main: - jobs: - - php56-build - - php70-build - - php71-build - - php72-build - - php73-build - - php74-build - -version: 2 - -job-references: - mysql_image: &mysql_image - circleci/mysql:5.6 - - setup_environment: &setup_environment - name: "Setup Environment Variables" - command: | - echo "export PATH=$HOME/.composer/vendor/bin:$PATH" >> $BASH_ENV - source /home/circleci/.bashrc - - install_dependencies: &install_dependencies - name: "Install Dependencies" - command: | - sudo apt-get update && sudo apt-get install subversion - sudo -E docker-php-ext-install mysqli - sudo sh -c "printf '\ndeb http://ftp.us.debian.org/debian sid main\n' >> /etc/apt/sources.list" - sudo apt-get update && sudo apt-get install mysql-client-5.7 - - php_job: &php_job - environment: - - WP_TESTS_DIR: "/tmp/wordpress-tests-lib" - - WP_CORE_DIR: "/tmp/wordpress/" - steps: - - checkout - - run: *setup_environment - - run: *install_dependencies - - run: - name: "Run Tests" - command: | - composer global require "phpunit/phpunit=5.7.*" - composer global require wp-coding-standards/wpcs - phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs - phpcs - rm -rf $WP_TESTS_DIR $WP_CORE_DIR - bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest - phpunit - WP_MULTISITE=1 phpunit - -jobs: - php56-build: - <<: *php_job - docker: - - image: circleci/php:5.6 - - image: *mysql_image - steps: - - checkout - - run: *setup_environment - - run: *install_dependencies - - run: - name: "Run Tests" - command: | - composer global require "phpunit/phpunit=5.7.*" - composer global require wp-coding-standards/wpcs - phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs - phpcs - SKIP_DB_CREATE=false - rm -rf $WP_TESTS_DIR $WP_CORE_DIR - bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 5.5 $SKIP_DB_CREATE - phpunit - WP_MULTISITE=1 phpunit - SKIP_DB_CREATE=true - rm -rf $WP_TESTS_DIR $WP_CORE_DIR - bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest $SKIP_DB_CREATE - phpunit - WP_MULTISITE=1 phpunit - SKIP_DB_CREATE=true - rm -rf $WP_TESTS_DIR $WP_CORE_DIR - bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 trunk $SKIP_DB_CREATE - phpunit - WP_MULTISITE=1 phpunit - SKIP_DB_CREATE=true - - php70-build: - <<: *php_job - docker: - - image: circleci/php:7.0 - - image: *mysql_image - - php71-build: - <<: *php_job - docker: - - image: circleci/php:7.1 - - image: *mysql_image - - php72-build: - <<: *php_job - docker: - - image: circleci/php:7.2 - - image: *mysql_image - - php73-build: - <<: *php_job - docker: - - image: circleci/php:7.3 - - image: *mysql_image - - php74-build: - <<: *php_job - docker: - - image: circleci/php:7.4 - - image: *mysql_image -- 2.39.5 From f070a2d48d76a9bd7f399f92d2d4751b8afd20f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 00:41:02 +0200 Subject: [PATCH 25/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 05e47b8..ea79fec 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -47,6 +47,6 @@ jobs: run: bash bin/install-wp-tests.sh wordpress_test root root localhost latest - name: Unit Testing - run: ./vendor/bin/phpunit + run: phpunit env: PHP_VERSION: ${{ matrix.php-versions }} -- 2.39.5 From 337afe84fb7ad9110beabfaf6c4b3861e590de22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 00:49:22 +0200 Subject: [PATCH 26/50] test --- .forgejo/workflows/phpunit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index ea79fec..5d18ef8 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -46,6 +46,8 @@ jobs: - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root localhost latest + - run: cat /tmp/wordpress/wp-config.php + - name: Unit Testing run: phpunit env: -- 2.39.5 From 1dfbf0e293ff9088606a79eedf746588083fbe8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 00:55:09 +0200 Subject: [PATCH 27/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 5d18ef8..679a19e 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -46,7 +46,7 @@ jobs: - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root localhost latest - - run: cat /tmp/wordpress/wp-config.php + - run: ls /tmp/wordpress/ - name: Unit Testing run: phpunit -- 2.39.5 From aa6e816196087b6ac70c721ea62c447096730167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 07:36:54 +0200 Subject: [PATCH 28/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 679a19e..7073a0f 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -46,7 +46,7 @@ jobs: - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root localhost latest - - run: ls /tmp/wordpress/ + - run: cat /tmp/wordpress-tests-lib/wp-tests-config.php - name: Unit Testing run: phpunit -- 2.39.5 From 0dba6d112777d7e65bae226eb0f96893117f13ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 07:44:23 +0200 Subject: [PATCH 29/50] test --- tests/bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 72f381a..85995cd 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,12 +11,16 @@ if ( ! $_tests_dir ) { $_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; } +echo $_tests_dir; + // Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file. $_phpunit_polyfills_path = getenv( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ); if ( false !== $_phpunit_polyfills_path ) { define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path ); } +echo WP_TESTS_PHPUNIT_POLYFILLS_PATH; + if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) { echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped exit( 1 ); -- 2.39.5 From a084db60d10d9af3448cdbf44e75bf6a75a8899a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 07:48:16 +0200 Subject: [PATCH 30/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 7073a0f..2b54af1 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -44,7 +44,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root localhost latest + run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest - run: cat /tmp/wordpress-tests-lib/wp-tests-config.php -- 2.39.5 From 13741a4e18bb73e9dbb5686a0befdbb7477dc2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 07:50:33 +0200 Subject: [PATCH 31/50] test --- tests/bootstrap.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 85995cd..72f381a 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -11,16 +11,12 @@ if ( ! $_tests_dir ) { $_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; } -echo $_tests_dir; - // Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file. $_phpunit_polyfills_path = getenv( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ); if ( false !== $_phpunit_polyfills_path ) { define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path ); } -echo WP_TESTS_PHPUNIT_POLYFILLS_PATH; - if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) { echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped exit( 1 ); -- 2.39.5 From 97b62577cac3a71726e53256e9828bdc8ec66722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:01:13 +0200 Subject: [PATCH 32/50] test --- .forgejo/workflows/phpunit.yml | 5 +++-- tests/bootstrap.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 2b54af1..7bc8ec0 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -43,11 +43,12 @@ jobs: - name: Install mysqladmin run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client + - name: Clone plugin dependencies + run: git clone https://code.event-federation.eu/Event-Federation/wordpress-activitypub.git /tmp/wordpress/wp-content/plugins/activitypub/ + - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest - - run: cat /tmp/wordpress-tests-lib/wp-tests-config.php - - name: Unit Testing run: phpunit env: diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 72f381a..7d30eb9 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -29,7 +29,7 @@ require_once "{$_tests_dir}/includes/functions.php"; * Manually load the plugin being tested. */ function _manually_load_plugin() { - require dirname( dirname( __FILE__ ) ) . '/activitypub-event-extensions.php'; + require dirname( __DIR__ ) . '/activitypub-event-extensions.php'; } tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); -- 2.39.5 From b6b766a059f0b2190f46539a5e1ebd54dfc7cc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:09:05 +0200 Subject: [PATCH 33/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 7bc8ec0..08b270b 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -50,6 +50,6 @@ jobs: run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest - name: Unit Testing - run: phpunit + run: ./vendor/bin/phpunit env: PHP_VERSION: ${{ matrix.php-versions }} -- 2.39.5 From 8e8f4fc9647024e9e8b2adf7e195b0cac9e22137 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:14:52 +0200 Subject: [PATCH 34/50] test --- .forgejo/workflows/phpunit.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 08b270b..76f80ed 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -23,13 +23,6 @@ jobs: - name: Checkout uses: https://code.forgejo.org/actions/checkout@v4 - # - name: Cache composer dependencies - # id: cache-primes - # uses: actions/cache@v4 - # with: - # path: /root/.cache/composer - # key: cache-1 - - name: Setup PHP uses: https://github.com/shivammathur/setup-php@v2 with: @@ -50,6 +43,6 @@ jobs: run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest - name: Unit Testing - run: ./vendor/bin/phpunit + run: cd /tmp/wordpress/wp-content/plugins/activitypub-event-extensions && ./vendor/bin/phpunit env: PHP_VERSION: ${{ matrix.php-versions }} -- 2.39.5 From eed3f1897e06d9d33c30c51b9b654e49e7a9894f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:20:16 +0200 Subject: [PATCH 35/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 76f80ed..854fcb2 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -43,6 +43,6 @@ jobs: run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest - name: Unit Testing - run: cd /tmp/wordpress/wp-content/plugins/activitypub-event-extensions && ./vendor/bin/phpunit + run: cd /workspace/Event-Federation/wordpress-activitypub-event-extensions/ && ./vendor/bin/phpunit env: PHP_VERSION: ${{ matrix.php-versions }} -- 2.39.5 From c1ec8997cc7a99e6e196d39dd7baa896818c3d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:26:57 +0200 Subject: [PATCH 36/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 854fcb2..a10fc2c 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -43,6 +43,6 @@ jobs: run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest - name: Unit Testing - run: cd /workspace/Event-Federation/wordpress-activitypub-event-extensions/ && ./vendor/bin/phpunit + run: cd /workspace/Event-Federation/wordpress-activitypub-event-extensions/ && phpunit env: PHP_VERSION: ${{ matrix.php-versions }} -- 2.39.5 From 1ffd799d6be8be4f3363467fdb76ef4ec1253a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:34:57 +0200 Subject: [PATCH 37/50] test --- .forgejo/workflows/phpunit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index a10fc2c..5c1cacc 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -39,6 +39,8 @@ jobs: - name: Clone plugin dependencies run: git clone https://code.event-federation.eu/Event-Federation/wordpress-activitypub.git /tmp/wordpress/wp-content/plugins/activitypub/ + - run: rm -r /tmp/wordpress/ && rm -r /tmp/wordpress-tests-lib/ + - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest -- 2.39.5 From 67d7c8cf721b8d92836cbdf475b57fd0528c1ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:44:46 +0200 Subject: [PATCH 38/50] test --- .forgejo/workflows/phpunit.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 5c1cacc..e5bb2c3 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -4,6 +4,11 @@ on: branches: - main pull_request: + +env: + WP_TESTS_DIR: /workspace/wordpress-test-lib/ + WP_CORE_DIR: /workspace/wordpress/ + jobs: phpunit: runs-on: ubuntu-latest @@ -39,8 +44,6 @@ jobs: - name: Clone plugin dependencies run: git clone https://code.event-federation.eu/Event-Federation/wordpress-activitypub.git /tmp/wordpress/wp-content/plugins/activitypub/ - - run: rm -r /tmp/wordpress/ && rm -r /tmp/wordpress-tests-lib/ - - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest -- 2.39.5 From 99040231ba61e68cb9b31bfe2510ad5ee9b73b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 08:52:37 +0200 Subject: [PATCH 39/50] test --- .forgejo/workflows/phpunit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index e5bb2c3..628cbf0 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -42,7 +42,7 @@ jobs: run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - name: Clone plugin dependencies - run: git clone https://code.event-federation.eu/Event-Federation/wordpress-activitypub.git /tmp/wordpress/wp-content/plugins/activitypub/ + run: git clone https://code.event-federation.eu/Event-Federation/wordpress-activitypub.git $WP_CORE_DIR/wp-content/plugins/activitypub/ - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest -- 2.39.5 From c300fa8c3603d4bfd71f7408ff9e0bbcaf0cbcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:07:27 +0200 Subject: [PATCH 40/50] test --- .forgejo/workflows/phpunit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 628cbf0..eba5f27 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -47,6 +47,8 @@ jobs: - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest + - run: ls -l $WP_CORE_DIR && ls -l $WP_CORE_DIR/wp-includes && ls -l $WP_CORE_DIR/wp-includes/PHPMailer/ + - name: Unit Testing run: cd /workspace/Event-Federation/wordpress-activitypub-event-extensions/ && phpunit env: -- 2.39.5 From b708494389a18fa332bf1737b66398882840d6bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:13:38 +0200 Subject: [PATCH 41/50] test --- .forgejo/workflows/phpunit.yml | 2 +- .woodpecker/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index eba5f27..87a545a 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -45,7 +45,7 @@ jobs: run: git clone https://code.event-federation.eu/Event-Federation/wordpress-activitypub.git $WP_CORE_DIR/wp-content/plugins/activitypub/ - name: Setup Test Environment - run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 latest + run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 - run: ls -l $WP_CORE_DIR && ls -l $WP_CORE_DIR/wp-includes && ls -l $WP_CORE_DIR/wp-includes/PHPMailer/ diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml index fe28da6..7e61820 100644 --- a/.woodpecker/test.yml +++ b/.woodpecker/test.yml @@ -14,6 +14,6 @@ steps: - docker-php-ext-enable mbstring mysqli pdo_mysql intl gd zip bz2 - composer require --dev yoast/phpunit-polyfills:"^3.0" - composer install - - bash bin/install-wp-tests.sh wordpress_tests root mysql mysql latest true + - bash bin/install-wp-tests.sh wordpress_tests root mysql mysql 6.6 true - phpunit --configuration phpunit.xml.dist -- 2.39.5 From 811c5a9ec85f15474fc43f26d3d6134fcca04bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:21:19 +0200 Subject: [PATCH 42/50] test --- bin/install-wp-tests.sh | 1 + 1 file changed, 1 insertion(+) mode change 100755 => 100644 bin/install-wp-tests.sh diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh old mode 100755 new mode 100644 index c6f53dc..88f2a57 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -54,6 +54,7 @@ fi set -ex install_wp() { + rm -rf $WP_CORE_DIR if [ -d $WP_CORE_DIR ]; then return; -- 2.39.5 From 7acce049e2c085b2bdc0e70bc41060e31c465cb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:21:47 +0200 Subject: [PATCH 43/50] test --- .forgejo/workflows/phpunit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 87a545a..cbfad79 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -6,8 +6,8 @@ on: pull_request: env: - WP_TESTS_DIR: /workspace/wordpress-test-lib/ - WP_CORE_DIR: /workspace/wordpress/ + WP_TESTS_DIR: /workspace/wordpress-test-lib + WP_CORE_DIR: /workspace/wordpress jobs: phpunit: -- 2.39.5 From 4fcfa97d0d60de53489d0371374b30c4c525bc5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:31:19 +0200 Subject: [PATCH 44/50] test --- .forgejo/workflows/phpunit.yml | 3 --- bin/install-wp-tests.sh | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index cbfad79..57079a2 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -41,9 +41,6 @@ jobs: - name: Install mysqladmin run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client - - name: Clone plugin dependencies - run: git clone https://code.event-federation.eu/Event-Federation/wordpress-activitypub.git $WP_CORE_DIR/wp-content/plugins/activitypub/ - - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index 88f2a57..e772021 100644 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -177,6 +177,12 @@ install_db() { fi } +install_wp_plugins() { + 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/ +} + install_wp +install_wp_plugins install_test_suite install_db -- 2.39.5 From 83961dbb527df9c454eacb22698da3ddabea2ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:40:30 +0200 Subject: [PATCH 45/50] test --- phpunit.xml.dist | 1 - tests/{test-sample.php => test-class-sample.php} | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) rename tests/{test-sample.php => test-class-sample.php} (85%) mode change 100755 => 100644 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 50421ec..e8e8560 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,6 @@ ./tests/ - ./tests/test-sample.php diff --git a/tests/test-sample.php b/tests/test-class-sample.php old mode 100755 new mode 100644 similarity index 85% rename from tests/test-sample.php rename to tests/test-class-sample.php index 0ab7270..3e9bf11 --- a/tests/test-sample.php +++ b/tests/test-class-sample.php @@ -8,7 +8,7 @@ /** * Sample test case. */ -class SampleTest extends WP_UnitTestCase { +class Test_Sample extends WP_UnitTestCase { /** * A single example test. -- 2.39.5 From 81f74fdafbdf209f325ca0d59f0627f9b1fc91a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:45:49 +0200 Subject: [PATCH 46/50] test --- .forgejo/workflows/phpunit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 57079a2..732e5fd 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -34,6 +34,8 @@ jobs: php-version: ${{ matrix.php-versions }} coverage: none tools: composer, phpunit-polyfills + env: + runner: self-hosted - name: Install Composer dependencies for PHP uses: "ramsey/composer-install@v1" -- 2.39.5 From d4f8e1386d3b1fd6f1d68730c8803e0781e8c5bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:53:13 +0200 Subject: [PATCH 47/50] test --- .forgejo/workflows/demo.yml | 6 ----- .forgejo/workflows/phpcs.yml | 40 ++++++++++++++++++++++++++++++++++ .forgejo/workflows/phpunit.yml | 4 +--- 3 files changed, 41 insertions(+), 9 deletions(-) delete mode 100755 .forgejo/workflows/demo.yml create mode 100755 .forgejo/workflows/phpcs.yml diff --git a/.forgejo/workflows/demo.yml b/.forgejo/workflows/demo.yml deleted file mode 100755 index 6010460..0000000 --- a/.forgejo/workflows/demo.yml +++ /dev/null @@ -1,6 +0,0 @@ -on: [push] -jobs: - test: - runs-on: ubuntu-latest - steps: - - run: echo All Good diff --git a/.forgejo/workflows/phpcs.yml b/.forgejo/workflows/phpcs.yml new file mode 100755 index 0000000..d47322a --- /dev/null +++ b/.forgejo/workflows/phpcs.yml @@ -0,0 +1,40 @@ +name: Unit Testing +on: + push: + branches: + - main + pull_request: + +jobs: + phpunit: + runs-on: ubuntu-latest + services: + mysql: + image: mariadb + env: + MYSQL_ROOT_PASSWORD: root + strategy: + matrix: + php-versions: ['8.1'] + name: Run phpunit tests + env: + extensions: mysql + key: cache-v1 + steps: + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + + - name: Setup PHP + uses: https://github.com/shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + tools: composer, cs2pr + env: + runner: self-hosted + + - name: Install Composer dependencies for PHP + uses: ramsey/composer-install@v3 + + - name: Detect coding standard violations + run: phpcs \ No newline at end of file diff --git a/.forgejo/workflows/phpunit.yml b/.forgejo/workflows/phpunit.yml index 732e5fd..0daeb73 100644 --- a/.forgejo/workflows/phpunit.yml +++ b/.forgejo/workflows/phpunit.yml @@ -38,7 +38,7 @@ jobs: runner: self-hosted - name: Install Composer dependencies for PHP - uses: "ramsey/composer-install@v1" + uses: ramsey/composer-install@v3 - name: Install mysqladmin run: sudo apt update && sudo apt -y upgrade && sudo apt -y install mysql-client @@ -46,8 +46,6 @@ jobs: - name: Setup Test Environment run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 6.6 - - run: ls -l $WP_CORE_DIR && ls -l $WP_CORE_DIR/wp-includes && ls -l $WP_CORE_DIR/wp-includes/PHPMailer/ - - name: Unit Testing run: cd /workspace/Event-Federation/wordpress-activitypub-event-extensions/ && phpunit env: -- 2.39.5 From 837d8b13b23e16a963d95732f1cb5346c096e915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 09:55:25 +0200 Subject: [PATCH 48/50] test --- .forgejo/workflows/phpcs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/phpcs.yml b/.forgejo/workflows/phpcs.yml index d47322a..6d24ee2 100755 --- a/.forgejo/workflows/phpcs.yml +++ b/.forgejo/workflows/phpcs.yml @@ -37,4 +37,4 @@ jobs: uses: ramsey/composer-install@v3 - name: Detect coding standard violations - run: phpcs \ No newline at end of file + run: ./vendor/bin/phpcs \ No newline at end of file -- 2.39.5 From 53a6e267aab44e463a6229b8d209099bcb03753a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 10:28:39 +0200 Subject: [PATCH 49/50] fix phpcs tests --- .forgejo/workflows/phpcs.yml | 7 +- .phpcs.xml.dist | 176 ++++++++++++++---- activitypub-event-extensions.php | 8 +- .../transformer/class-events-manager.php | 2 + .../transformer/class-gatherpress.php | 2 + includes/admin/class-settings-page.php | 2 +- phpunit.xml.dist => phpunit.xml | 0 templates/settings.php | 4 +- 8 files changed, 158 insertions(+), 43 deletions(-) rename phpunit.xml.dist => phpunit.xml (100%) diff --git a/.forgejo/workflows/phpcs.yml b/.forgejo/workflows/phpcs.yml index 6d24ee2..4db1ac5 100755 --- a/.forgejo/workflows/phpcs.yml +++ b/.forgejo/workflows/phpcs.yml @@ -1,4 +1,5 @@ -name: Unit Testing +name: PHP Code Checker + on: push: branches: @@ -6,7 +7,7 @@ on: pull_request: jobs: - phpunit: + phpcs: runs-on: ubuntu-latest services: mysql: @@ -16,7 +17,7 @@ jobs: strategy: matrix: php-versions: ['8.1'] - name: Run phpunit tests + name: Run PHP Code Checker env: extensions: mysql key: cache-v1 diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index df58068..d7cc4f5 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -1,47 +1,157 @@ - - Generally-applicable sniffs for WordPress plugins. + + + A custom set of rules to check for a WPized WordPress project + + - . - /vendor/ - /node_modules/ - - - - - - - - + + /docroot/wp-admin/* + /docroot/wp-includes/* + /docroot/wp-*.php + /docroot/index.php + /docroot/xmlrpc.php + /docroot/wp-content/plugins/* - - - - - + + /vendor/* - - - - - - - - - - + + /node_modules/* + + + *.min.js + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + - + + - + + + - + + + + + + + tests/*.php + templates/*.php + + + tests/*.php + + + tests/*.php + + + \ No newline at end of file diff --git a/activitypub-event-extensions.php b/activitypub-event-extensions.php index 392601a..d106516 100644 --- a/activitypub-event-extensions.php +++ b/activitypub-event-extensions.php @@ -44,7 +44,7 @@ Activitypub_Event_Extensions\Setup::get_instance(); * * @todo This filter is temporary code needed to do local testing. */ -add_filter( 'http_request_host_is_external', 'custom_http_request_host_is_external', 10, 3 ); +add_filter( 'http_request_host_is_external', 'activitypub_event_extensions_custom_http_request_host_is_external', 10, 3 ); /** * Add a filter for http_request_host_is_external @@ -55,7 +55,7 @@ add_filter( 'http_request_host_is_external', 'custom_http_request_host_is_extern * * @todo This filter is temporary code needed to do local testing. */ -function custom_http_request_host_is_external( $is_external ) { +function activitypub_event_extensions_custom_http_request_host_is_external( $is_external ) { $is_external = true; return $is_external; @@ -68,11 +68,11 @@ function custom_http_request_host_is_external( $is_external ) { * * @todo This filter is temporary code needed to do local testing. */ -add_filter( 'https_ssl_verify', 'dont_verify_local_dev_https', 10, 3 ); +add_filter( 'https_ssl_verify', 'activitypub_event_extensions_dont_verify_local_dev_https', 10, 3 ); /** * TODO: remove it. */ -function dont_verify_local_dev_https() { +function activitypub_event_extensions_dont_verify_local_dev_https() { return false; } diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php index e6b52bd..4cbc71d 100644 --- a/includes/activitypub/transformer/class-events-manager.php +++ b/includes/activitypub/transformer/class-events-manager.php @@ -6,6 +6,8 @@ * @license AGPL-3.0-or-later */ +namespace Activitypub_Event_Extensions\Activitypub\Transformer; + use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer; use EM_Event; use Activitypub\Activity\Extended_Object\Event; diff --git a/includes/activitypub/transformer/class-gatherpress.php b/includes/activitypub/transformer/class-gatherpress.php index c875ed1..d04e4a6 100644 --- a/includes/activitypub/transformer/class-gatherpress.php +++ b/includes/activitypub/transformer/class-gatherpress.php @@ -6,6 +6,8 @@ * @license AGPL-3.0-or-later */ +namespace Activitypub_Event_Extensions\Activitypub\Transformer; + use Activitypub_Event_Extensions\Activitypub\Transformer\Event; use Activitypub\Model\Blog; use Activitypub\Activity\Extended_Object\Event as Event_Object; diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index dbe5ed5..d7cc288 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -37,7 +37,7 @@ class Settings_Page { public static function admin_menu(): void { \add_options_page( 'Activitypub Event Extension', - __( 'ActivityPub Events', 'activitypub_event_extensions' ), + __( 'ActivityPub Events', 'activitypub-event-extensions' ), 'manage_options', self::SETTINGS_SLUG, array( self::STATIC, 'settings_page' ) diff --git a/phpunit.xml.dist b/phpunit.xml similarity index 100% rename from phpunit.xml.dist rename to phpunit.xml diff --git a/templates/settings.php b/templates/settings.php index aab3640..df52492 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -76,7 +76,7 @@ $current_category_mapping = \get_option( 'activitypub_event_extensions_ev

-

+

@@ -96,7 +96,7 @@ $current_category_mapping = \get_option( 'activitypub_event_extensions_ev

-

+

-- 2.39.5 From 574f770a654a5848e6815a093c38e5147335a385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 21 Sep 2024 10:56:51 +0200 Subject: [PATCH 50/50] fix phpcs --- activitypub-event-extensions.php | 16 +++++----------- .../transformer/class-events-manager.php | 6 ++++-- .../transformer/class-the-events-calendar.php | 12 ++++-------- includes/class-setup.php | 2 +- includes/plugins/class-the-events-calendar.php | 8 ++++++-- 5 files changed, 20 insertions(+), 24 deletions(-) diff --git a/activitypub-event-extensions.php b/activitypub-event-extensions.php index d106516..9be6461 100644 --- a/activitypub-event-extensions.php +++ b/activitypub-event-extensions.php @@ -35,25 +35,21 @@ Activitypub_Event_Extensions\Autoloader::register(); // Initialize the plugin. Activitypub_Event_Extensions\Setup::get_instance(); -// For local development purposes: TODO. Remove everything after here. +// BeforeFirstRelease: Remove everything after this after here. /** * Add a filter for http_request_host_is_external * - * TODO: Remove this for release. - * - * @todo This filter is temporary code needed to do local testing. + * BeforeFirstRelease: Remove this for release. */ add_filter( 'http_request_host_is_external', 'activitypub_event_extensions_custom_http_request_host_is_external', 10, 3 ); /** * Add a filter for http_request_host_is_external * - * TODO: Remove this for release. + * BeforeFirstRelease: Remove this for release. * * @param bool $is_external Whether the request is external. - * - * @todo This filter is temporary code needed to do local testing. */ function activitypub_event_extensions_custom_http_request_host_is_external( $is_external ) { $is_external = true; @@ -64,14 +60,12 @@ function activitypub_event_extensions_custom_http_request_host_is_external( $is_ /** * Don't verify ssl certs for testing. * - * TODO: Remove this for release. - * - * @todo This filter is temporary code needed to do local testing. + * BeforeFirstRelease: Remove this for release. */ add_filter( 'https_ssl_verify', 'activitypub_event_extensions_dont_verify_local_dev_https', 10, 3 ); /** - * TODO: remove it. + * BeforeFirstRelease: remove it. */ function activitypub_event_extensions_dont_verify_local_dev_https() { return false; diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php index 4cbc71d..487181c 100644 --- a/includes/activitypub/transformer/class-events-manager.php +++ b/includes/activitypub/transformer/class-events-manager.php @@ -9,6 +9,8 @@ namespace Activitypub_Event_Extensions\Activitypub\Transformer; use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer; +use DateTime; +use DateTimeZone; use EM_Event; use Activitypub\Activity\Extended_Object\Event; use Activitypub\Activity\Extended_Object\Place; @@ -153,7 +155,7 @@ final class Events_Manager extends Event_Transformer { /** * Return the remaining attendee capacity * - * @todo decide whether to include pending bookings or not! + * @return int */ public function get_remaining_attendee_capacity() { $em_bookings = $this->em_event->get_bookings()->get_bookings(); @@ -166,7 +168,7 @@ final class Events_Manager extends Event_Transformer { * * @return int */ - public function get_participant_count() { + public function get_participant_count(): int { $em_bookings = $this->em_event->get_bookings()->get_bookings(); return count( $em_bookings->bookings ); } diff --git a/includes/activitypub/transformer/class-the-events-calendar.php b/includes/activitypub/transformer/class-the-events-calendar.php index aa5a16b..e1b42fb 100644 --- a/includes/activitypub/transformer/class-the-events-calendar.php +++ b/includes/activitypub/transformer/class-the-events-calendar.php @@ -51,8 +51,6 @@ final class The_Events_Calendar extends Event { * @return string|null tribe category if it exists */ public function get_tribe_category() { - // TODO: make it possible that one event can have multiple categories? - // Using cat_slugs isn't the best way to do this, don't know if it's a good idea. $categories = tribe_get_event_cat_slugs( $this->wp_object->ID ); if ( count( $categories ) === 0 ) { @@ -133,12 +131,10 @@ final class The_Events_Calendar extends Event { protected function get_content() { $content = parent::get_content(); - // TODO: remove link at the end of the content. - - // TODO: add organizer - // $this->tribe_event->organizers[0]. - - // TODO: do add Cancelled reason in the content (maybe at the end). + // /BeforeFirstRelease: + // * remove link at the end of the content. + // * add organizer. + // * do add Cancelled reason in the content.s return $content; } diff --git a/includes/class-setup.php b/includes/class-setup.php index 67f1999..2de709f 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -60,7 +60,7 @@ class Setup { */ protected function __construct() { $this->activitypub_plugin_is_active = is_plugin_active( 'activitypub/activitypub.php' ); - // TODO: decide whether we want to do anything at all when ActivityPub plugin is note active. + // BeforeFirstRelease: decide whether we want to do anything at all when ActivityPub plugin is note active. // if ( ! $this->activitypub_plugin_is_active ) { // deactivate_plugins( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE ); // return; diff --git a/includes/plugins/class-the-events-calendar.php b/includes/plugins/class-the-events-calendar.php index 1b77a61..6f18a5a 100644 --- a/includes/plugins/class-the-events-calendar.php +++ b/includes/plugins/class-the-events-calendar.php @@ -46,8 +46,12 @@ final class The_Events_Calendar extends Event_plugin { * @return string The settings page url. */ public static function get_settings_page(): string { - // TODO: Tribe\Events\Admin\Settings::settings_page_id. - return 'edit.php?post_type=tribe_events&page=tec-events-settings'; + if ( class_exists( '\Tribe\Events\Admin\Settings' ) ) { + $page = \Tribe\Events\Admin\Settings::$settings_page_id; + } else { + $page = 'tec-events-settings'; + } + return sprintf( 'edit.php?post_type=tribe_events&page=%s', $page ); } /** -- 2.39.5