From 33944254f68d3e0fcca7998d43513c357941ebf8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 May 2024 14:30:26 +0000 Subject: [PATCH 1/6] Update yoast/phpunit-polyfills requirement from ^1.1 to ^2.0 Updates the requirements on [yoast/phpunit-polyfills](https://github.com/Yoast/PHPUnit-Polyfills) to permit the latest version. - [Release notes](https://github.com/Yoast/PHPUnit-Polyfills/releases) - [Changelog](https://github.com/Yoast/PHPUnit-Polyfills/blob/2.x/CHANGELOG.md) - [Commits](https://github.com/Yoast/PHPUnit-Polyfills/compare/1.1.0...2.0.1) --- updated-dependencies: - dependency-name: yoast/phpunit-polyfills dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 140e4e3..963a057 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "wp-cli/rewrite-command": "^2.0", "wp-cli/wp-cli-tests": "^4.2.9", "wpackagist-plugin/glotpress": "^4.0.0", - "yoast/phpunit-polyfills": "^1.1" + "yoast/phpunit-polyfills": "^2.0" }, "suggest": { "wpackagist-plugin/slack": "Send Slack notifications for various events" From 4d6b82fd231e9a847ff4ceaeb18d799e1fcc38db Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 30 May 2024 14:06:12 +0200 Subject: [PATCH 2/6] Add fixes to accommodate for PHPUnit 10 [dependabot skip] --- composer.json | 4 +++- .../tests/Behat => behat}/FeatureContext.php | 1 + tests/phpunit/tests/Configuration.php | 1 + tests/phpunit/tests/Export.php | 1 + tests/phpunit/tests/Loader/Git.php | 2 +- tests/phpunit/tests/Loader/Mercurial.php | 2 +- tests/phpunit/tests/Loader/Subversion.php | 2 +- tests/phpunit/tests/LoaderFactory.php | 4 ++-- tests/phpunit/tests/Project.php | 1 + tests/phpunit/tests/ProjectLocator.php | 1 + tests/phpunit/tests/Repository/Bitbucket.php | 2 +- tests/phpunit/tests/Repository/GitHub.php | 2 +- tests/phpunit/tests/Repository/GitLab.php | 2 +- tests/phpunit/tests/RepositoryFactory.php | 3 ++- tests/phpunit/tests/RestrictedSiteAccess.php | 1 + tests/phpunit/tests/Runner.php | 1 + tests/phpunit/tests/TranslationApiRoute.php | 4 ++-- tests/phpunit/tests/Updater.php | 1 + .../tests/WebhookHandler/Bitbucket.php | 2 +- tests/phpunit/tests/WebhookHandler/GitHub.php | 2 +- tests/phpunit/tests/WebhookHandler/GitLab.php | 2 +- .../tests/WebhookHandler/LegacyGitHub.php | 2 +- tests/phpunit/tests/ZipProvider.php | 7 +++--- tests/phpunit/{tests => utils}/TestCase.php | 10 ++++++++- tests/phpunit/utils/TestCase_Route.php | 22 +++++++++++++++++++ 25 files changed, 61 insertions(+), 21 deletions(-) rename tests/{phpunit/tests/Behat => behat}/FeatureContext.php (99%) rename tests/phpunit/{tests => utils}/TestCase.php (82%) create mode 100644 tests/phpunit/utils/TestCase_Route.php diff --git a/composer.json b/composer.json index 963a057..0fe2c9f 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "wp-cli/rewrite-command": "^2.0", "wp-cli/wp-cli-tests": "^4.2.9", "wpackagist-plugin/glotpress": "^4.0.0", - "yoast/phpunit-polyfills": "^2.0" + "yoast/phpunit-polyfills": "^2.0.1" }, "suggest": { "wpackagist-plugin/slack": "Send Slack notifications for various events" @@ -73,6 +73,8 @@ }, "autoload-dev": { "psr-4": { + "Required\\Traduttore\\Tests\\Behat\\": "tests/behat", + "Required\\Traduttore\\Tests\\Utils\\": "tests/phpunit/utils", "Required\\Traduttore\\Tests\\": "tests/phpunit/tests" } }, diff --git a/tests/phpunit/tests/Behat/FeatureContext.php b/tests/behat/FeatureContext.php similarity index 99% rename from tests/phpunit/tests/Behat/FeatureContext.php rename to tests/behat/FeatureContext.php index 5fd10f1..df10562 100644 --- a/tests/phpunit/tests/Behat/FeatureContext.php +++ b/tests/behat/FeatureContext.php @@ -15,6 +15,7 @@ use WP_CLI\Tests\Context\FeatureContext as WP_CLI_FeatureContext; use WP_CLI\Utils; use function WP_CLI\Tests\Context\wp_cli_behat_env_debug; +use function WP_CLI\Utils; /** * Feature tests context class with Traduttore-specific steps. diff --git a/tests/phpunit/tests/Configuration.php b/tests/phpunit/tests/Configuration.php index c0e29a7..5e86b55 100644 --- a/tests/phpunit/tests/Configuration.php +++ b/tests/phpunit/tests/Configuration.php @@ -5,6 +5,7 @@ namespace Required\Traduttore\Tests; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Configuration as Config; /** diff --git a/tests/phpunit/tests/Export.php b/tests/phpunit/tests/Export.php index 88c913c..36ba98d 100644 --- a/tests/phpunit/tests/Export.php +++ b/tests/phpunit/tests/Export.php @@ -5,6 +5,7 @@ namespace Required\Traduttore\Tests; +use Required\Traduttore\Tests\Utils\TestCase; use PO; use Required\Traduttore\Export as E; diff --git a/tests/phpunit/tests/Loader/Git.php b/tests/phpunit/tests/Loader/Git.php index 13ee09a..21059c7 100644 --- a/tests/phpunit/tests/Loader/Git.php +++ b/tests/phpunit/tests/Loader/Git.php @@ -5,10 +5,10 @@ namespace Required\Traduttore\Tests\Loader; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Loader\Git as GitLoader; use Required\Traduttore\Project; use Required\Traduttore\Repository\GitHub; -use Required\Traduttore\Tests\TestCase; /** * Test cases for \Required\Traduttore\Loader\Git. diff --git a/tests/phpunit/tests/Loader/Mercurial.php b/tests/phpunit/tests/Loader/Mercurial.php index b130d0f..7eb00a3 100644 --- a/tests/phpunit/tests/Loader/Mercurial.php +++ b/tests/phpunit/tests/Loader/Mercurial.php @@ -5,10 +5,10 @@ namespace Required\Traduttore\Tests\Loader; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Loader\Mercurial as MercurialLoader; use Required\Traduttore\Project; use Required\Traduttore\Repository\Bitbucket; -use Required\Traduttore\Tests\TestCase; /** * Test cases for \Required\Traduttore\Loader\Mercurial. diff --git a/tests/phpunit/tests/Loader/Subversion.php b/tests/phpunit/tests/Loader/Subversion.php index e0ffa86..2e40c79 100644 --- a/tests/phpunit/tests/Loader/Subversion.php +++ b/tests/phpunit/tests/Loader/Subversion.php @@ -5,10 +5,10 @@ namespace Required\Traduttore\Tests\Loader; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Loader\Subversion as SubversionLoader; use Required\Traduttore\Project; use Required\Traduttore\Repository\Bitbucket; -use Required\Traduttore\Tests\TestCase; /** * Test cases for \Required\Traduttore\Loader\Subversion. diff --git a/tests/phpunit/tests/LoaderFactory.php b/tests/phpunit/tests/LoaderFactory.php index ad367a1..d80ba40 100644 --- a/tests/phpunit/tests/LoaderFactory.php +++ b/tests/phpunit/tests/LoaderFactory.php @@ -5,12 +5,12 @@ namespace Required\Traduttore\Tests; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Loader\Git; use Required\Traduttore\Loader\Mercurial; - +use Required\Traduttore\LoaderFactory as Factory; use Required\Traduttore\Project; use Required\Traduttore\Repository; -use Required\Traduttore\LoaderFactory as Factory; use Required\Traduttore\Repository\Bitbucket; use Required\Traduttore\Repository\GitHub; use Required\Traduttore\Repository\GitLab; diff --git a/tests/phpunit/tests/Project.php b/tests/phpunit/tests/Project.php index 00abd5b..5ff5910 100644 --- a/tests/phpunit/tests/Project.php +++ b/tests/phpunit/tests/Project.php @@ -8,6 +8,7 @@ use DateTime; use DateTimeZone; use GP_Project; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project as TraduttoreProject; /** diff --git a/tests/phpunit/tests/ProjectLocator.php b/tests/phpunit/tests/ProjectLocator.php index d7be4e5..ca8a58c 100644 --- a/tests/phpunit/tests/ProjectLocator.php +++ b/tests/phpunit/tests/ProjectLocator.php @@ -5,6 +5,7 @@ namespace Required\Traduttore\Tests; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\ProjectLocator as Locator; diff --git a/tests/phpunit/tests/Repository/Bitbucket.php b/tests/phpunit/tests/Repository/Bitbucket.php index 9cfdc3f..2722613 100644 --- a/tests/phpunit/tests/Repository/Bitbucket.php +++ b/tests/phpunit/tests/Repository/Bitbucket.php @@ -5,10 +5,10 @@ namespace Required\Traduttore\Tests\Repository; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\Repository; use Required\Traduttore\Repository\Bitbucket as BitbucketRepository; -use Required\Traduttore\Tests\TestCase; /** * Test cases for \Required\Traduttore\Repository\Bitbucket. diff --git a/tests/phpunit/tests/Repository/GitHub.php b/tests/phpunit/tests/Repository/GitHub.php index 41bd894..ab77a08 100644 --- a/tests/phpunit/tests/Repository/GitHub.php +++ b/tests/phpunit/tests/Repository/GitHub.php @@ -5,10 +5,10 @@ namespace Required\Traduttore\Tests\Repository; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\Repository; use Required\Traduttore\Repository\GitHub as GitHubRepository; -use Required\Traduttore\Tests\TestCase; /** * Test cases for \Required\Traduttore\Repository\GitHub. diff --git a/tests/phpunit/tests/Repository/GitLab.php b/tests/phpunit/tests/Repository/GitLab.php index 5d0865f..33288d5 100644 --- a/tests/phpunit/tests/Repository/GitLab.php +++ b/tests/phpunit/tests/Repository/GitLab.php @@ -5,10 +5,10 @@ namespace Required\Traduttore\Tests\Repository; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\Repository; use Required\Traduttore\Repository\GitLab as GitLabRepository; -use Required\Traduttore\Tests\TestCase; /** * Test cases for \Required\Traduttore\Repository\GitLab. diff --git a/tests/phpunit/tests/RepositoryFactory.php b/tests/phpunit/tests/RepositoryFactory.php index b378b24..5fc1cc6 100644 --- a/tests/phpunit/tests/RepositoryFactory.php +++ b/tests/phpunit/tests/RepositoryFactory.php @@ -5,10 +5,11 @@ namespace Required\Traduttore\Tests; +use Required\Traduttore\Tests\Utils\TestCase; +use Required\Traduttore\Project; use Required\Traduttore\Repository\Bitbucket; use Required\Traduttore\Repository\GitHub; use Required\Traduttore\Repository\GitLab; -use Required\Traduttore\Project; use Required\Traduttore\RepositoryFactory as Factory; /** diff --git a/tests/phpunit/tests/RestrictedSiteAccess.php b/tests/phpunit/tests/RestrictedSiteAccess.php index a47301a..81085f8 100644 --- a/tests/phpunit/tests/RestrictedSiteAccess.php +++ b/tests/phpunit/tests/RestrictedSiteAccess.php @@ -5,6 +5,7 @@ namespace Required\Traduttore\Tests; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Plugin; /** diff --git a/tests/phpunit/tests/Runner.php b/tests/phpunit/tests/Runner.php index 0c0c022..82b81b7 100644 --- a/tests/phpunit/tests/Runner.php +++ b/tests/phpunit/tests/Runner.php @@ -5,6 +5,7 @@ namespace Required\Traduttore\Tests; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Loader\Git as Loader; use Required\Traduttore\Project; use Required\Traduttore\Runner as R; diff --git a/tests/phpunit/tests/TranslationApiRoute.php b/tests/phpunit/tests/TranslationApiRoute.php index a722d89..3dc033c 100644 --- a/tests/phpunit/tests/TranslationApiRoute.php +++ b/tests/phpunit/tests/TranslationApiRoute.php @@ -9,7 +9,7 @@ use GP_Locale; use GP_Translation_Set; use GP_UnitTest_Factory; -use GP_UnitTestCase_Route; +use Required\Traduttore\Tests\Utils\TestCase_Route; use ReflectionClass; use Required\Traduttore\TranslationApiRoute as Route; use Required\Traduttore\ZipProvider as Provider; @@ -17,7 +17,7 @@ /** * Test cases for \Required\Traduttore\TranslationApiRoute. */ -class TranslationApiRoute extends GP_UnitTestCase_Route { +class TranslationApiRoute extends TestCase_Route { /** * @var class-string */ diff --git a/tests/phpunit/tests/Updater.php b/tests/phpunit/tests/Updater.php index 0a1475d..c64b641 100644 --- a/tests/phpunit/tests/Updater.php +++ b/tests/phpunit/tests/Updater.php @@ -6,6 +6,7 @@ namespace Required\Traduttore\Tests; use GP; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Configuration; use Required\Traduttore\Project; use Required\Traduttore\Updater as U; diff --git a/tests/phpunit/tests/WebhookHandler/Bitbucket.php b/tests/phpunit/tests/WebhookHandler/Bitbucket.php index 5c00786..f6a284f 100644 --- a/tests/phpunit/tests/WebhookHandler/Bitbucket.php +++ b/tests/phpunit/tests/WebhookHandler/Bitbucket.php @@ -5,9 +5,9 @@ namespace Required\Traduttore\Tests\WebhookHandler; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\Repository; -use Required\Traduttore\Tests\TestCase; use WP_REST_Request; /** diff --git a/tests/phpunit/tests/WebhookHandler/GitHub.php b/tests/phpunit/tests/WebhookHandler/GitHub.php index 0d00c43..f7dc835 100644 --- a/tests/phpunit/tests/WebhookHandler/GitHub.php +++ b/tests/phpunit/tests/WebhookHandler/GitHub.php @@ -5,9 +5,9 @@ namespace Required\Traduttore\Tests\WebhookHandler; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\Repository; -use Required\Traduttore\Tests\TestCase; use WP_REST_Request; /** diff --git a/tests/phpunit/tests/WebhookHandler/GitLab.php b/tests/phpunit/tests/WebhookHandler/GitLab.php index eebaa6a..19597df 100644 --- a/tests/phpunit/tests/WebhookHandler/GitLab.php +++ b/tests/phpunit/tests/WebhookHandler/GitLab.php @@ -5,9 +5,9 @@ namespace Required\Traduttore\Tests\WebhookHandler; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\Repository; -use Required\Traduttore\Tests\TestCase; use WP_REST_Request; /** diff --git a/tests/phpunit/tests/WebhookHandler/LegacyGitHub.php b/tests/phpunit/tests/WebhookHandler/LegacyGitHub.php index 4bc801d..f18d72d 100644 --- a/tests/phpunit/tests/WebhookHandler/LegacyGitHub.php +++ b/tests/phpunit/tests/WebhookHandler/LegacyGitHub.php @@ -5,9 +5,9 @@ namespace Required\Traduttore\Tests\WebhookHandler; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\Project; use Required\Traduttore\Repository; -use Required\Traduttore\Tests\TestCase; use WP_REST_Request; /** diff --git a/tests/phpunit/tests/ZipProvider.php b/tests/phpunit/tests/ZipProvider.php index 5145dac..4269fb6 100644 --- a/tests/phpunit/tests/ZipProvider.php +++ b/tests/phpunit/tests/ZipProvider.php @@ -7,6 +7,7 @@ use DateTime; use GP; +use Required\Traduttore\Tests\Utils\TestCase; use Required\Traduttore\ProjectLocator; use Required\Traduttore\ZipProvider as Provider; use Translations; @@ -161,11 +162,9 @@ public function test_generate_zip_file(): void { $this->assertTrue( $provider->generate_zip_file() ); } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - */ public function test_generate_zip_file_missing_wp_filesystem(): void { + unset( $GLOBALS['wp_filesystem'] ); + $original = $this->factory()->original->create( [ 'project_id' => $this->translation_set->project_id ] ); $this->factory()->translation->create( diff --git a/tests/phpunit/tests/TestCase.php b/tests/phpunit/utils/TestCase.php similarity index 82% rename from tests/phpunit/tests/TestCase.php rename to tests/phpunit/utils/TestCase.php index c0c3619..27dda8e 100644 --- a/tests/phpunit/tests/TestCase.php +++ b/tests/phpunit/utils/TestCase.php @@ -3,7 +3,7 @@ * Class TestCase */ -namespace Required\Traduttore\Tests; +namespace Required\Traduttore\Tests\Utils; use GP_UnitTest_Factory; use GP_UnitTestCase; @@ -44,4 +44,12 @@ protected function assertErrorResponse( mixed $code, WP_REST_Response|WP_Error $ $this->assertSame( $status, $data['status'] ); } } + + /** + * Temporary workaround to allow the tests to run on PHPUnit 10. + * + * @link https://core.trac.wordpress.org/ticket/59486 + */ + public function expectDeprecated(): void { + } } diff --git a/tests/phpunit/utils/TestCase_Route.php b/tests/phpunit/utils/TestCase_Route.php new file mode 100644 index 0000000..f565089 --- /dev/null +++ b/tests/phpunit/utils/TestCase_Route.php @@ -0,0 +1,22 @@ + Date: Thu, 30 May 2024 14:09:49 +0200 Subject: [PATCH 3/6] Lint fixes [dependabot skip] --- tests/phpunit/utils/TestCase.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/utils/TestCase.php b/tests/phpunit/utils/TestCase.php index 27dda8e..d206f1c 100644 --- a/tests/phpunit/utils/TestCase.php +++ b/tests/phpunit/utils/TestCase.php @@ -7,7 +7,6 @@ use GP_UnitTest_Factory; use GP_UnitTestCase; -use WP_Error; use WP_REST_Response; /** @@ -29,8 +28,12 @@ protected static function factory(): GP_UnitTest_Factory { /** * @see WP_Test_REST_TestCase + * + * @param int|string $code Error code. + * @param \WP_REST_Response|\WP_Error $response Response. + * @param int|null $status Status code. */ - protected function assertErrorResponse( mixed $code, WP_REST_Response|WP_Error $response, mixed $status = null ): void { + protected function assertErrorResponse( mixed $code, WP_REST_Response|\WP_Error $response, mixed $status = null ): void { if ( $response instanceof WP_REST_Response ) { $response = $response->as_error(); } From 9ec155f946ded18bae7e719b642b0e325072cda5 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 30 May 2024 14:11:21 +0200 Subject: [PATCH 4/6] Composer normalize [dependabot skip] --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 0fe2c9f..a95388b 100644 --- a/composer.json +++ b/composer.json @@ -73,9 +73,9 @@ }, "autoload-dev": { "psr-4": { + "Required\\Traduttore\\Tests\\": "tests/phpunit/tests", "Required\\Traduttore\\Tests\\Behat\\": "tests/behat", - "Required\\Traduttore\\Tests\\Utils\\": "tests/phpunit/utils", - "Required\\Traduttore\\Tests\\": "tests/phpunit/tests" + "Required\\Traduttore\\Tests\\Utils\\": "tests/phpunit/utils" } }, "config": { From 238ab4103fc4f86d19c774cdc37d5744a2e45585 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 30 May 2024 14:13:32 +0200 Subject: [PATCH 5/6] Update PHPUnit config [dependabot skip] --- phpunit.xml.dist | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0c50b69..a6fa365 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,21 +1,13 @@ - - - - ./tests/phpunit/tests - ./tests/phpunit/tests/TestCase.php - - - - - inc - - + + + + ./tests/phpunit/tests + + + + + inc + + From 5ab5e6307e5477dc4077ca81ced4c0d76f14053a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 30 May 2024 14:13:40 +0200 Subject: [PATCH 6/6] Update `.gitignore` [dependabot skip] --- .gitignore | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 59f3442..cd99b7f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,7 @@ # PHPUnit /coverage*.xml .phpunit.result.cache +.phpunit.cache # Behat *.log - -# Build process -/build