Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
php-version: '8.4'
coverage: 'none'
tools: composer, cs2pr

Expand Down
38 changes: 15 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,40 @@ jobs:
name: PHPUnit ${{ matrix.php }}
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
ports:
- 3306/tcp
env:
MYSQL_ROOT_PASSWORD: password
# Set health checks to wait until mysql has started
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3

strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.3' ]
php: [ '8.4', '8.5' ]

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: 'none'
tools: composer

- name: Install dependencies
- name: Install Composer dependencies
uses: ramsey/composer-install@v2
with:
composer-options: "--no-progress --no-ansi --no-interaction"

- name: Install WordPress test setup
run: bash bin/install-wp-tests.sh wordpress_test root password 127.0.0.1:${{ job.services.mysql.ports[3306] }} latest
- name: Install wp-env
run: npm -g install @wordpress/env --force

- name: Override PHP version
run: echo '{ "phpVersion":"${{ matrix.php }}" }' > .wp-env.override.json

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Start wp-env
run: wp-env start

- name: Run tests
env:
WP_TESTS_DIR: /tmp/wordpress-tests-lib/
run: vendor/bin/phpunit
run: wp-env run tests-cli --env-cwd=wp-content/plugins/wporg-gp-translation-events ./vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .wp-env.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"core": null,
"phpVersion": "8.3",
"phpVersion": "8.4",
"plugins": [
"GlotPress/GlotPress",
"https://downloads.wordpress.org/plugin/sqlite-object-cache.1.3.7.zip",
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"description": "",
"license": "GPL-2.0-only",
"require-dev": {
"phpunit/phpunit": "^9.6.16",
"yoast/phpunit-polyfills": "^2.0.0",
"phpunit/phpunit": "^9.6.16 || ^10.0 || ^11.0",
"yoast/phpunit-polyfills": "^2.0.0 || ^3.0",
"wp-coding-standards/wpcs": "^3.0"
},
"scripts":{
Expand Down
3 changes: 0 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite name="tests">
Expand Down
13 changes: 9 additions & 4 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
}

function _glotpress_path( string $path ): string {
$glotpress_path = dirname( __DIR__, 2 ) . '/glotpress/';
if ( getenv( 'GITHUB_ACTIONS' ) ) {
$glotpress_path = '/tmp/wordpress/wp-content/plugins/glotpress/';
$plugins_dir = dirname( __DIR__, 2 );

// GlotPress may be installed as 'glotpress' or 'GlotPress' depending on the environment.
foreach ( array( 'glotpress', 'GlotPress' ) as $dir_name ) {
if ( is_dir( $plugins_dir . '/' . $dir_name ) ) {
return $plugins_dir . '/' . $dir_name . '/' . $path;
}
}

return $glotpress_path . $path;
// Fallback to lowercase.
return $plugins_dir . '/glotpress/' . $path;
}

// Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file.
Expand Down