Skip to content

Commit

Permalink
Merge pull request #2878 from Parsely/update/add-php-8.4-to-tests-and…
Browse files Browse the repository at this point in the history
…-move-pcov-to-php-8.2-retry
  • Loading branch information
acicovic authored Nov 1, 2024
2 parents 6af894e + d7e6372 commit a92c539
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 38 deletions.
39 changes: 15 additions & 24 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,25 @@ jobs:
WP_VERSION: ${{ matrix.wp }}

strategy:
# PHP 7.2 uses PHPUnit 8.5.21
# PHP 7.3 uses PHPUnit 9.5.10
# PHP 7.4 uses PHPUnit 9.5.10
# PHP 8.0 uses PHPUnit 9.5.10
# PHP 8.1 uses PHPUnit 9.5.10
# PHP 8.2 uses PHPUnit 9.5.10
# Note: Different PHP versions use different PHPUnit versions.
# Keys:
# - coverage: Whether to run the tests with code coverage.
# - experimental: Whether the build is "allowed to fail".
matrix:
php: [ '7.2', '7.3', '7.4', '8.0']
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.3']
wp: ['latest']
coverage: [none]
experimental: [false]
include:
- php: '8.1'
coverage: pcov
- php: '8.2'
coverage: pcov # Warning: PCOV might not work for PHP 8.4 or newer according to https://thephp.cc/articles/pcov-or-xdebug.
extensions: pcov
ini-values: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\""
experimental: false
- php: '8.2'
wp: 'trunk'
coverage: none
experimental: false
- php: '8.3'
- php: '8.4'
wp: 'trunk'
coverage: none
experimental: false
experimental: true
fail-fast: false
continue-on-error: ${{ matrix.experimental }}
steps:
Expand Down Expand Up @@ -91,18 +82,18 @@ jobs:
- name: Prepare environment for integration tests
run: composer prepare-ci --no-interaction

- name: Run integration tests (single site)
if: ${{ matrix.php != 8.0 && ! matrix.experimental }}
- name: Run integration tests
if: ${{ !matrix.experimental && matrix.coverage == 'none' }}
run: composer testwp --no-interaction

- name: Run integration tests experimental
- name: Run integration tests (multisite)
if: ${{ !matrix.experimental && matrix.coverage == 'none' }}
run: composer testwp-ms --no-interaction

- name: Run integration tests (experimental)
if: ${{ matrix.experimental }}
run: composer testwp-experimental --no-interaction

- name: Run integration tests (multi site)
if: ${{ matrix.php != 8.0 && ! matrix.experimental }}
run: composer testwp-ms --no-interaction

- name: Run integration tests (multisite site with code coverage)
if: ${{ matrix.php == 8.1 }}
- name: Run integration tests (multisite with code coverage)
if: ${{ matrix.coverage == 'pcov' }}
run: composer coveragewp-ci --no-interaction
15 changes: 7 additions & 8 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,24 @@ jobs:
WP_VERSION: latest

strategy:
# PHP 7.2 uses PHPUnit 8.5.21
# PHP 7.3 uses PHPUnit 9.5.10
# PHP 7.4 uses PHPUnit 9.5.10
# PHP 8.0 uses PHPUnit 9.5.10
# PHP 8.1 uses PHPUnit 9.5.10
# Note: Different PHP versions use different PHPUnit versions.
# Keys:
# - coverage: Whether to run the tests with code coverage.
# - experimental: Whether the build is "allowed to fail".
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.2', '8.3']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.3']
coverage: [none]
experimental: [false]
include:
# Run code coverage for only one PHP version
- php: '8.1'
coverage: pcov
- php: '8.2'
coverage: pcov # Warning: PCOV might not work for PHP 8.4 or newer according to https://thephp.cc/articles/pcov-or-xdebug.
extensions: pcov
ini-values: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\""
experimental: false
- php: '8.4'
coverage: none
experimental: true
fail-fast: false
continue-on-error: ${{ matrix.experimental }}
steps:
Expand Down
1 change: 1 addition & 0 deletions phpunit-experimental.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<server name="SERVER_PORT" value="80"/>
<server name="HTTP_HOST" value="localhost"/>
<server name="REMOTE_ADDR" value="127.0.0.1"/>
<const name="INTEGRATION_TESTS_RUNNING" value="true"/>
</php>
<testsuites>
<testsuite name="integration">
Expand Down
2 changes: 1 addition & 1 deletion src/class-parsely.php
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ public function set_default_content_helper_settings_values(): void {
* for context (Default null for current).
* @return string
*/
public static function get_settings_url( int $_blog_id = null ): string {
public static function get_settings_url( ?int $_blog_id = null ): string {
return get_admin_url( $_blog_id, 'options-general.php?page=' . self::MENU_SLUG );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function is_pch_feature_enabled_for_user(): bool {
* @param WP_REST_Request|null $request The request object.
* @return bool|WP_Error True if the endpoint is available.
*/
public function is_available_to_current_user( WP_REST_Request $request = null ) {
public function is_available_to_current_user( ?WP_REST_Request $request = null ) {
$can_use_feature = $this->is_pch_feature_enabled_for_user();

if ( ! $can_use_feature ) {
Expand Down
8 changes: 4 additions & 4 deletions src/services/content-api/class-content-api-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ protected function register_endpoints(): void {
*/
public function get_post_details(
string $url,
string $period_start = null,
string $period_end = null
?string $period_start = null,
?string $period_end = null
) {
/** @var Endpoints\Endpoint_Analytics_Post_Details $endpoint */
$endpoint = $this->get_endpoint( '/analytics/post/detail' );
Expand Down Expand Up @@ -116,8 +116,8 @@ public function get_post_details(
*/
public function get_post_referrers(
string $url,
string $period_start = null,
string $period_end = null
?string $period_start = null,
?string $period_end = null
) {
/** @var Endpoints\Endpoint_Referrers_Post_Detail $endpoint */
$endpoint = $this->get_endpoint( '/referrers/post/detail' );
Expand Down

0 comments on commit a92c539

Please sign in to comment.