Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ed259b1
Update phpunit.yml
obenland Jul 7, 2024
1f2d25b
Update composer.json
obenland Jul 7, 2024
b526fe9
Update composer.json
obenland Jul 7, 2024
dc69832
vcdfds
obenland Jul 7, 2024
31935f5
xvsdvfs
obenland Jul 7, 2024
14c30c5
Update phpunit.yml
obenland Jul 7, 2024
8039e5c
Update phpunit.yml
obenland Jul 7, 2024
f19b83b
Update phpunit.yml
obenland Jul 7, 2024
71b43da
Update phpunit.yml
obenland Jul 7, 2024
6a7add5
Update phpunit.yml
obenland Jul 7, 2024
66122dc
Update phpunit.yml
obenland Jul 7, 2024
ac0e8fc
Update phpunit.yml
obenland Jul 7, 2024
b277ba6
Update phpunit.yml
obenland Jul 7, 2024
d1be934
Update phpunit.yml
obenland Jul 7, 2024
c1affd0
Update phpunit.yml
obenland Jul 7, 2024
dae9451
Update phpunit.yml
obenland Jul 7, 2024
63df05b
Update phpunit.yml
obenland Jul 7, 2024
dc9a94e
Update phpunit.yml
obenland Jul 8, 2024
598e6bc
Update phpunit.yml
obenland Jul 8, 2024
fe23597
Update phpunit.yml
obenland Jul 8, 2024
19aed92
Update phpunit.yml
obenland Jul 8, 2024
3b5b1ef
Update phpunit.yml
obenland Jul 8, 2024
c65a6e1
Update phpunit.yml
obenland Jul 8, 2024
3777294
#
obenland Jul 8, 2024
16ff479
Update phpunit.yml
obenland Jul 8, 2024
5cc466a
Update phpunit.yml
obenland Jul 8, 2024
7f3421e
Update phpunit.yml
obenland Jul 8, 2024
15194db
#
obenland Jul 9, 2024
0555960
#
obenland Jul 9, 2024
b7ba790
#
obenland Jul 9, 2024
5516519
#
obenland Jul 9, 2024
ca8c785
#
obenland Jul 9, 2024
dc2023f
Update phpunit.yml
obenland Jul 9, 2024
0a36316
Update phpunit.yml
obenland Jul 9, 2024
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
72 changes: 49 additions & 23 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,67 @@
name: PHPUnit

on: [push]

env:
WP_TESTS_DIR: /github/home/wp-tests/wordpress-tests-lib
WP_CORE_DIR: /github/home/wp-tests/wordpress
on: [push, pull_request]

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ 7.4 ]
wordpress-version: [ latest ]
container:
image: junaidbhura/wp-tests:php-${{ matrix.php-version }}
php-versions: ['7.4', '8.1', '8.2', '8.3']
wordpress-versions: ['latest', '4.7']

services:
mysql:
image: mysql:5.7.27
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_PASSWORD: rootpassword
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Checkout repository
uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, mysqli
coverage: xdebug

- name: Start MySQL Service
run: |
sudo systemctl start mysql.service
sudo systemctl status mysql.service

- name: Install Composer dependencies
- name: Get Composer Cache Directory
id: composer-cache
run: |
composer install --no-dev
composer global require "phpunit/phpunit=5.7.27"
composer global require "yoast/phpunit-polyfills=1.1.0"
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-

- name: Install dependencies
run: |
composer require --dev phpunit/phpunit:^6.1 --no-update
composer install --prefer-dist --no-progress

- name: Install WordPress test suite
run: bash bin/install-wp-tests.sh wordpress_test root root mysql ${{ matrix.wordpress-version }}
env:
WP_VERSION: ${{ matrix.wordpress-versions }}
run: |
if [ "$WP_VERSION" = "4.7" ]; then
bash bin/install-wp-tests.sh wordpress_test root rootpassword 127.0.0.1:${{ job.services.mysql.ports['3306'] }} $WP_VERSION false 4.7.9
else
bash bin/install-wp-tests.sh wordpress_test root rootpassword 127.0.0.1:${{ job.services.mysql.ports['3306'] }} $WP_VERSION
fi

- name: Tests
run: |
$HOME/.composer/vendor/bin/phpunit --config=phpunit.xml
WP_MULTISITE=1 $HOME/.composer/vendor/bin/phpunit --config=phpunit.xml
- name: Run PHPUnit tests
run: |
vendor/bin/phpunit
WP_MULTISITE=1 vendor/bin/phpunit
53 changes: 19 additions & 34 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation] [test-suite-version]"
exit 1
fi

Expand All @@ -11,29 +11,23 @@ DB_PASS=$3
DB_HOST=${4-localhost}
WP_VERSION=${5-latest}
SKIP_DB_CREATE=${6-false}
TEST_SUITE_VERSION=${7-latest}

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 [ `which curl` ]; then
curl -s "$1" > "$2";
elif [ `which wget` ]; then
wget -nv -O "$2" "$1"
fi
}

if [[ $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
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
WP_TESTS_TAG="tags/$WP_VERSION"
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then
WP_TESTS_TAG="trunk"
else
Expand All @@ -48,6 +42,12 @@ else
WP_TESTS_TAG="tags/$LATEST_VERSION"
fi

if [[ $TEST_SUITE_VERSION == 'latest' ]]; then
TEST_SUITE_TAG=$WP_TESTS_TAG
else
TEST_SUITE_TAG="tags/$TEST_SUITE_VERSION"
fi

set -ex

install_wp() {
Expand All @@ -65,22 +65,6 @@ install_wp() {
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
Expand All @@ -103,15 +87,16 @@ install_test_suite() {
if [ ! -d $WP_TESTS_DIR ]; then
# set up testing suite
mkdir -p $WP_TESTS_DIR
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data
svn co --quiet https://develop.svn.wordpress.org/${TEST_SUITE_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes
svn co --quiet https://develop.svn.wordpress.org/${TEST_SUITE_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
download https://develop.svn.wordpress.org/${TEST_SUITE_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
Expand Down
14 changes: 6 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"require": {
"php": "^7.2|^8.0"
"php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"yoast/phpunit-polyfills": "^1.0.3",
"mockery/mockery": "1.2",
"brain/monkey": "2.*",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
"wp-coding-standards/wpcs": "^2.3"
"yoast/phpunit-polyfills": "^1.0",
"wp-coding-standards/wpcs": "^3.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0"
},
"config": {
"allow-plugins": {
Expand All @@ -26,6 +23,7 @@
}
},
"scripts": {
"test": "phpunit --config=tests/phpunit.xml"
"test": "phpunit",
"phpcs": "phpcs"
}
}
51 changes: 0 additions & 51 deletions package-lock.json

This file was deleted.