Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update yoast/phpunit-polyfills requirement from ^1.1 to ^2.0 #271

Merged
merged 6 commits into from
May 30, 2024
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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
# PHPUnit
/coverage*.xml
.phpunit.result.cache
.phpunit.cache

# Behat
*.log

# Build process
/build
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.1"
},
"suggest": {
"wpackagist-plugin/slack": "Send Slack notifications for various events"
Expand All @@ -73,7 +73,9 @@
},
"autoload-dev": {
"psr-4": {
"Required\\Traduttore\\Tests\\": "tests/phpunit/tests"
"Required\\Traduttore\\Tests\\": "tests/phpunit/tests",
"Required\\Traduttore\\Tests\\Behat\\": "tests/behat",
"Required\\Traduttore\\Tests\\Utils\\": "tests/phpunit/utils"
}
},
"config": {
Expand Down
30 changes: 11 additions & 19 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
<?xml version="1.0"?>
<phpunit
bootstrap="tests/phpunit/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<testsuites>
<testsuite name="glotpress">
<directory suffix=".php">./tests/phpunit/tests</directory>
<exclude>./tests/phpunit/tests/TestCase.php</exclude>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">inc</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/phpunit/bootstrap.php" backupGlobals="false" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Traduttore">
<directory suffix=".php">./tests/phpunit/tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">inc</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Required\Traduttore\Tests;

use Required\Traduttore\Tests\Utils\TestCase;
use Required\Traduttore\Configuration as Config;

/**
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Required\Traduttore\Tests;

use Required\Traduttore\Tests\Utils\TestCase;
use PO;
use Required\Traduttore\Export as E;

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Loader/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Loader/Mercurial.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Loader/Subversion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/LoaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use DateTime;
use DateTimeZone;
use GP_Project;
use Required\Traduttore\Tests\Utils\TestCase;
use Required\Traduttore\Project as TraduttoreProject;

/**
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/ProjectLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Required\Traduttore\Tests;

use Required\Traduttore\Tests\Utils\TestCase;
use Required\Traduttore\Project;
use Required\Traduttore\ProjectLocator as Locator;

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Repository/Bitbucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Repository/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/Repository/GitLab.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/tests/RepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/RestrictedSiteAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Required\Traduttore\Tests;

use Required\Traduttore\Tests\Utils\TestCase;
use Required\Traduttore\Plugin;

/**
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/TranslationApiRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
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;

/**
* Test cases for \Required\Traduttore\TranslationApiRoute.
*/
class TranslationApiRoute extends GP_UnitTestCase_Route {
class TranslationApiRoute extends TestCase_Route {
/**
* @var class-string
*/
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/tests/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/WebhookHandler/Bitbucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/WebhookHandler/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/WebhookHandler/GitLab.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/WebhookHandler/LegacyGitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
7 changes: 3 additions & 4 deletions tests/phpunit/tests/ZipProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
* Class TestCase
*/

namespace Required\Traduttore\Tests;
namespace Required\Traduttore\Tests\Utils;

use GP_UnitTest_Factory;
use GP_UnitTestCase;
use WP_Error;
use WP_REST_Response;

/**
Expand All @@ -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();
}
Expand All @@ -44,4 +47,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 {
}
}
22 changes: 22 additions & 0 deletions tests/phpunit/utils/TestCase_Route.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
* Class TestCase_Route
*/

namespace Required\Traduttore\Tests\Utils;

use GP_UnitTestCase_Route;

/**
* Base TestCase class for custom routes.
*/
class TestCase_Route extends GP_UnitTestCase_Route {

/**
* Temporary workaround to allow the tests to run on PHPUnit 10.
*
* @link https://core.trac.wordpress.org/ticket/59486
*/
public function expectDeprecated(): void {
}
}