diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 180b4934..e28c88d3 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 067dcb64..796c4360 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,29 +9,20 @@ 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: @@ -39,18 +30,19 @@ jobs: 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 diff --git a/.wp-env.json b/.wp-env.json index eede0128..d6e68c9e 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -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", diff --git a/composer.json b/composer.json index 504366c3..dfcee8d5 100644 --- a/composer.json +++ b/composer.json @@ -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":{ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4af023cb..3cbe17a9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,6 @@ bootstrap="tests/bootstrap.php" backupGlobals="false" colors="true" - convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" > diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a57bf205..1614f746 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -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.