From 01842f5f8b3bf90303c26efa58845a52a52b0769 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 11 Feb 2024 12:30:40 +0000 Subject: [PATCH 1/5] Composer: Add allow-plugins config --- composer.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composer.json b/composer.json index e390d98..ef1cd12 100644 --- a/composer.json +++ b/composer.json @@ -60,5 +60,11 @@ "support": { "issues": "https://github.com/Automattic/syndication/issues", "source": "https://github.com/Automattic/syndication" + }, + "config": { + "allow-plugins": { + "composer/installers": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } } } From bc0e2b31d08f25db8770791680a085d80b0f699c Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 11 Feb 2024 12:34:22 +0000 Subject: [PATCH 2/5] Composer: refresh dependencies --- composer.json | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index ef1cd12..179f4d1 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,13 @@ "composer/installers": "~1.0" }, "require-dev": { - "automattic/vipwpcs": "^2.2", - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7", + "automattic/vipwpcs": "^3", "php-parallel-lint/php-parallel-lint": "^1.0", "phpcompatibility/phpcompatibility-wp": "^2.1", - "phpunit/phpunit": "^4 || ^5 || ^6 || ^7", - "squizlabs/php_codesniffer": "^3.5", - "wp-coding-standards/wpcs": "^2.3.0", - "yoast/wp-test-utils": "^0.2.2" + "phpunit/phpunit": "^9", + "squizlabs/php_codesniffer": "^3.8", + "wp-coding-standards/wpcs": "^3.0", + "yoast/wp-test-utils": "^1.2" }, "scripts": { "cbf": [ From 79b59fc4b3ddce99495395a5a7992652d222f216 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 11 Feb 2024 12:49:14 +0000 Subject: [PATCH 3/5] Increase minimum PHP version Update versions in CI config files and action versions. --- .github/workflows/cs-lint.yml | 4 ++-- .github/workflows/integrations.yml | 31 +++++++----------------------- composer.json | 2 +- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/.github/workflows/cs-lint.yml b/.github/workflows/cs-lint.yml index fe4dac4..b71328b 100644 --- a/.github/workflows/cs-lint.yml +++ b/.github/workflows/cs-lint.yml @@ -22,7 +22,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "7.4" + php-version: "latest" coverage: none tools: cs2pr @@ -37,7 +37,7 @@ jobs: uses: korelstar/xmllint-problem-matcher@v1 - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 # Validate the composer.json file. # @link https://getcomposer.org/doc/03-cli.md#validate diff --git a/.github/workflows/integrations.yml b/.github/workflows/integrations.yml index 8f5577e..4f9a81b 100644 --- a/.github/workflows/integrations.yml +++ b/.github/workflows/integrations.yml @@ -13,33 +13,25 @@ on: jobs: test: name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }} - # Ubuntu-20.x includes MySQL 8.0, which causes `caching_sha2_password` issues with PHP < 7.4 - # https://www.php.net/manual/en/mysqli.requirements.php - # TODO: change to ubuntu-latest when we no longer support PHP < 7.4 - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: WP_VERSION: ${{ matrix.wordpress }} strategy: matrix: - wordpress: ["5.5", "5.6", "5.7"] - php: ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4"] + wordpress: ["5.9", "6.4"] + php: ["7.4", "8.3"] include: - - php: "8.0" - # Ignore platform requirements, so that PHPUnit 7.5 can be installed on PHP 8.0 (and above). - composer-options: "--ignore-platform-reqs" + - php: "8.3" extensions: pcov ini-values: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\"" coverage: pcov - exclude: - - php: "8.0" - wordpress: "5.5" fail-fast: false steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 @@ -52,15 +44,6 @@ jobs: - name: Setup problem matchers for PHP run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - # Setup PCOV since we're using PHPUnit < 8 which has it integrated. Requires PHP 7.1. - # Ignore platform reqs to make it install on PHP 8. - # https://github.com/krakjoe/pcov-clobber - - name: Setup PCOV - if: ${{ matrix.php == 8.0 }} - run: | - composer require pcov/clobber --ignore-platform-reqs - vendor/bin/pcov clobber - - name: Setup Problem Matchers for PHPUnit run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" @@ -76,10 +59,10 @@ jobs: run: composer prepare-ci - name: Run integration tests (single site) - if: ${{ matrix.php != 8.0 }} + if: ${{ matrix.php != 8.2 }} run: composer test - name: Run integration tests (single site with code coverage) - if: ${{ matrix.php == 8.0 }} + if: ${{ matrix.php == 8.2 }} run: composer coverage-ci - name: Run integration tests (multisite) run: composer test-ms diff --git a/composer.json b/composer.json index 179f4d1..ad1920e 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": ">=5.6", + "php": ">=7.4", "composer/installers": "~1.0" }, "require-dev": { From e1085ae93dfc65d7e77b4d5be78624132c00fe42 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 11 Feb 2024 13:05:15 +0000 Subject: [PATCH 4/5] Tests: Refresh config for PHPUnit 9 --- .gitignore | 3 ++- composer.json | 2 +- phpunit.xml.dist | 41 ++++++++++++++++++++--------- tests/class-encryptor-test-case.php | 2 +- tests/test-encryption.php | 2 +- tests/test-encryptor-mcrypt.php | 8 +++--- tests/test-encryptor-openssl.php | 4 +-- 7 files changed, 39 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index af1f417..3eb76cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -composer.lock +/.phpunit.cache +/composer.lock /vendor diff --git a/composer.json b/composer.json index ad1920e..500c5b6 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "bash bin/install-wp-tests.sh wordpress_test root root localhost" ], "test": [ - "@php ./vendor/bin/phpunit --testsuite WP_Tests" + "@php ./vendor/bin/phpunit --testsuite WP_Tests --no-coverage" ], "test-ms": [ "@putenv WP_MULTISITE=1", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9bc19d9..9a37836 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,32 @@ - + + - - - ./tests/ - - + + + tests + + + + + + push-syndication.php + includes + + diff --git a/tests/class-encryptor-test-case.php b/tests/class-encryptor-test-case.php index d6bd54a..8a983b2 100644 --- a/tests/class-encryptor-test-case.php +++ b/tests/class-encryptor-test-case.php @@ -16,7 +16,7 @@ abstract class EncryptorTestCase extends WPIntegrationTestCase { /** * Runs before the test, set-up. */ - public function setUp() { + public function set_up() { $this->simple_string = 'this is a simple string!'; $this->complex_array = array( 'element' => 'this is a element', diff --git a/tests/test-encryption.php b/tests/test-encryption.php index 2714234..b6cdaf8 100644 --- a/tests/test-encryption.php +++ b/tests/test-encryption.php @@ -14,7 +14,7 @@ class EncryptionTest extends WPIntegrationTestCase { /** * Runs before the test, set-up. */ - public function setUp() { + public function set_up() { $this->simple_string = 'this is a simple string!'; $this->complex_array = array( 'element' => 'this is a element', diff --git a/tests/test-encryptor-mcrypt.php b/tests/test-encryptor-mcrypt.php index 4480982..9aa7d9f 100644 --- a/tests/test-encryptor-mcrypt.php +++ b/tests/test-encryptor-mcrypt.php @@ -14,8 +14,8 @@ class EncryptorMCryptTest extends EncryptorTestCase { /** * Runs before the test, set-up. */ - public function setUp() { - parent::setUp(); + public function set_up() { + parent::set_up(); $this->encryptor = new \Syndication_Encryptor_MCrypt(); // Disable deprecation warning for this test, as it will run on PHP 7.1. This test will only ensure functionality of the @@ -27,10 +27,10 @@ public function setUp() { /** * Runs after the test. */ - public function tearDown() { + public function tear_down() { // Restore original error reporting. error_reporting( $this->error_reporting ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration_error_reporting - parent::tearDown(); + parent::tear_down(); } /** diff --git a/tests/test-encryptor-openssl.php b/tests/test-encryptor-openssl.php index fd5712d..50b90eb 100644 --- a/tests/test-encryptor-openssl.php +++ b/tests/test-encryptor-openssl.php @@ -11,8 +11,8 @@ class EncryptorOpenSSLTest extends EncryptorTestCase { /** * Runs before the test, set-up. */ - public function setUp() { - parent::setUp(); + public function set_up() { + parent::set_up(); $this->encryptor = new \Syndication_Encryptor_OpenSSL(); } From 9de31bebbe171c65e19082a29a883ae19e4d7c86 Mon Sep 17 00:00:00 2001 From: Gary Jones Date: Sun, 11 Feb 2024 13:06:16 +0000 Subject: [PATCH 5/5] PHP: Fix deprecation of optional parameters A required parameter can't be defined after an optional one. Only one use of this private call fortunately. --- includes/class-syndication-logger.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-syndication-logger.php b/includes/class-syndication-logger.php index ab5f834..597a30a 100644 --- a/includes/class-syndication-logger.php +++ b/includes/class-syndication-logger.php @@ -233,7 +233,7 @@ public static function log_post_info( $post_id, $status = '', $message = '', $lo * @param array $extra additional data */ private function log_post( $msg_type, $post_id, $status, $message, $log_time, $extra ) { - $this->log( $storage_type = 'object', $msg_type, $object_type = 'post', $object_id = $post_id, $status, $message, $log_time, $extra ); + $this->log( $storage_type = 'object', $msg_type, 'post', $post_id, $status, $message, $log_time, $extra ); } /** @@ -248,7 +248,7 @@ private function log_post( $msg_type, $post_id, $status, $message, $log_time, $e * @param array $extra additional data * @return mixed true or WP_Error */ - private function log( $storage_type, $msg_type, $object_type = 'post', $object_id = '', $status, $message, $log_time, $extra ) { + private function log( $storage_type, $msg_type, $object_type, $object_id, $status, $message, $log_time, $extra ) { // Don't log infos depending on debug level if ( 'info' == $msg_type && 'info' != $this->debug_level ) { return;