From 1352759026a2a7761c0ed76cda93ae1879714c93 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Thu, 21 Nov 2024 20:14:47 +0300 Subject: [PATCH] Removed testing polyfills that will be deprecated in next versions from Changelogger. (#40162) * Expanded the yoast/phpunit-polyfill package allowed versions. * Changelog. * Brought the v1 requirements back. * Removed unneeded polyfill in ChangeEntryTest. * ChangelogEntryTest fixes. * ChangelogTest fixes. * CommandLoaderTest fixes. * ConfigTest fix. * SemverVersioningTest fixes. * WordPressVersioningTest fixes. * UtilsTest fixes. * Static fixtures for parent test case. * AddCommandTest fixes. * SquashCommandTest fix. * VersionCommandTest fix. * VersionCommandTest fix. * WriteCommandTest fix. * Update projects/packages/changelogger/composer.json Co-authored-by: Brad Jorsch * Updated plugin lock files. * Changelogs. * Lock update." * Changelog. * Disabled GPG signing for test commits. * Try updating PHPUnit XML configuration. * Reverted PHPUnit configuration and polyfills back to original state. * Revert "Lock update."" This reverts commit 8b94c270a7668ed41d985028967a6ae6f8ab4250. * Revert "Changelogs." This reverts commit 310ec9399f9f99d33ef5594f18842e378ac6d3c0. * Revert "Updated plugin lock files." This reverts commit e27834878d0fcf47585e6e1af25d197a3771220b. * Revert "Changelog." This reverts commit d8b64ddaaf5248fa42178c75361342ab249766c4. * Disable global git config instead of disabling signatures. --------- Co-authored-by: Brandon Kraft Co-authored-by: Brad Jorsch --- .../changelogger/changelog/try-yoast-polyfill-upgrade | 5 +++++ .../tests/php/includes/lib/ParserTestCase.php | 6 +++--- .../tests/php/tests/lib/ChangeEntryTest.php | 5 ++--- .../tests/php/tests/lib/ChangelogEntryTest.php | 3 +-- .../tests/php/tests/lib/ChangelogTest.php | 3 +-- .../tests/php/tests/lib/KeepAChangelogParserTest.php | 4 ++-- .../tests/php/tests/src/AddCommandTest.php | 3 ++- .../tests/php/tests/src/CommandLoaderTest.php | 1 - .../changelogger/tests/php/tests/src/ConfigTest.php | 1 - .../php/tests/src/Plugins/SemverVersioningTest.php | 11 +++++------ .../php/tests/src/Plugins/WordpressVersioningTest.php | 11 +++++------ .../tests/php/tests/src/SquashCommandTest.php | 2 +- .../changelogger/tests/php/tests/src/UtilsTest.php | 6 +++--- .../tests/php/tests/src/ValidateCommandTest.php | 2 +- .../tests/php/tests/src/VersionCommandTest.php | 2 +- .../tests/php/tests/src/WriteCommandTest.php | 2 +- 16 files changed, 33 insertions(+), 34 deletions(-) create mode 100644 projects/packages/changelogger/changelog/try-yoast-polyfill-upgrade diff --git a/projects/packages/changelogger/changelog/try-yoast-polyfill-upgrade b/projects/packages/changelogger/changelog/try-yoast-polyfill-upgrade new file mode 100644 index 0000000000000..7d3c64a452c3e --- /dev/null +++ b/projects/packages/changelogger/changelog/try-yoast-polyfill-upgrade @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Upgraded dependency yoast/phpunit-polyfill to allow for upgrades. + + diff --git a/projects/packages/changelogger/tests/php/includes/lib/ParserTestCase.php b/projects/packages/changelogger/tests/php/includes/lib/ParserTestCase.php index 32ef490e4f1f3..bd35b426392e2 100644 --- a/projects/packages/changelogger/tests/php/includes/lib/ParserTestCase.php +++ b/projects/packages/changelogger/tests/php/includes/lib/ParserTestCase.php @@ -31,7 +31,7 @@ class ParserTestCase extends TestCase { * * @var string */ - protected $fixtures; + protected static $fixtures; /** * Set to update fixture files after running tests. @@ -275,9 +275,9 @@ public function testFixture( $filename ) { /** * Data provider for testFixture. */ - public function provideFixture() { + public static function provideFixture() { $ret = array(); - foreach ( glob( $this->fixtures ) as $filename ) { + foreach ( glob( static::$fixtures ) as $filename ) { $ret[ basename( $filename ) ] = array( $filename ); } return $ret; diff --git a/projects/packages/changelogger/tests/php/tests/lib/ChangeEntryTest.php b/projects/packages/changelogger/tests/php/tests/lib/ChangeEntryTest.php index b0212b5bda5ed..ddcd29b63bff4 100644 --- a/projects/packages/changelogger/tests/php/tests/lib/ChangeEntryTest.php +++ b/projects/packages/changelogger/tests/php/tests/lib/ChangeEntryTest.php @@ -18,7 +18,6 @@ * @covers \Automattic\Jetpack\Changelog\ChangeEntry */ class ChangeEntryTest extends TestCase { - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Test general getters. @@ -115,7 +114,7 @@ public function testCompare( ChangeEntry $a, ChangeEntry $b, array $config, $exp /** * Data provider for testCompare. */ - public function provideCompare() { + public static function provideCompare() { return array( 'Default config, equal' => array( new ChangeEntry( @@ -414,7 +413,7 @@ public function testJson( $json, $change ) { /** * Data provider for testJson. */ - public function provideJson() { + public static function provideJson() { return array( 'Basic serialization' => array( '{"__class__":"Automattic\\\\Jetpack\\\\Changelog\\\\ChangeEntry","significance":null,"timestamp":"2021-02-18T00:00:00+0000","subheading":"","author":"","content":""}', diff --git a/projects/packages/changelogger/tests/php/tests/lib/ChangelogEntryTest.php b/projects/packages/changelogger/tests/php/tests/lib/ChangelogEntryTest.php index 7715158b5c297..f2a913855e5d8 100644 --- a/projects/packages/changelogger/tests/php/tests/lib/ChangelogEntryTest.php +++ b/projects/packages/changelogger/tests/php/tests/lib/ChangelogEntryTest.php @@ -21,7 +21,6 @@ * @covers \Automattic\Jetpack\Changelog\ChangelogEntry */ class ChangelogEntryTest extends TestCase { - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Test general getters. @@ -239,7 +238,7 @@ public function testJson( $json, $entry ) { /** * Data provider for testJson. */ - public function provideJson() { + public static function provideJson() { return array( 'Basic serialization' => array( '{"__class__":"Automattic\\\\Jetpack\\\\Changelog\\\\ChangelogEntry","version":"1.0","link":null,"timestamp":"2021-02-18T00:00:00+0000","prologue":"","epilogue":"","changes":[]}', diff --git a/projects/packages/changelogger/tests/php/tests/lib/ChangelogTest.php b/projects/packages/changelogger/tests/php/tests/lib/ChangelogTest.php index 13bb87036379e..7ef90ac8116fc 100644 --- a/projects/packages/changelogger/tests/php/tests/lib/ChangelogTest.php +++ b/projects/packages/changelogger/tests/php/tests/lib/ChangelogTest.php @@ -18,7 +18,6 @@ * @covers \Automattic\Jetpack\Changelog\Changelog */ class ChangelogTest extends TestCase { - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Test prologue and epilogue. @@ -109,7 +108,7 @@ public function testJson( $json, $changelog ) { /** * Data provider for testJson. */ - public function provideJson() { + public static function provideJson() { return array( 'Basic serialization' => array( '{"__class__":"Automattic\\\\Jetpack\\\\Changelog\\\\Changelog","prologue":"","epilogue":"","entries":[]}', diff --git a/projects/packages/changelogger/tests/php/tests/lib/KeepAChangelogParserTest.php b/projects/packages/changelogger/tests/php/tests/lib/KeepAChangelogParserTest.php index 10a8d42724b70..d1b04dacfde09 100644 --- a/projects/packages/changelogger/tests/php/tests/lib/KeepAChangelogParserTest.php +++ b/projects/packages/changelogger/tests/php/tests/lib/KeepAChangelogParserTest.php @@ -17,6 +17,6 @@ * @covers \Automattic\Jetpack\Changelog\KeepAChangelogParser */ class KeepAChangelogParserTest extends ParserTestCase { - protected $className = KeepAChangelogParser::class; - protected $fixtures = __DIR__ . '/fixtures/KeepAChangelogParserTest.*.md'; + protected $className = KeepAChangelogParser::class; + protected static $fixtures = __DIR__ . '/fixtures/KeepAChangelogParserTest.*.md'; } diff --git a/projects/packages/changelogger/tests/php/tests/src/AddCommandTest.php b/projects/packages/changelogger/tests/php/tests/src/AddCommandTest.php index 9fe9509f6accd..8518b81089a24 100644 --- a/projects/packages/changelogger/tests/php/tests/src/AddCommandTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/AddCommandTest.php @@ -53,6 +53,7 @@ public function testGetDefaultFilename() { array( 'mustRun' => true, 'env' => array( + 'GIT_CONFIG_GLOBAL' => '/dev/null', 'GIT_AUTHOR_NAME' => 'Dummy', 'GIT_AUTHOR_EMAIL' => 'dummy@example.com', 'GIT_COMMITTER_NAME' => 'Dummy', @@ -163,7 +164,7 @@ public function testExecute( array $args, array $options, array $inputs, $expect /** * Data provider for testExecute. */ - public function provideExecute() { + public static function provideExecute() { $composerWithTypes = array( 'extra' => array( 'changelogger' => array( diff --git a/projects/packages/changelogger/tests/php/tests/src/CommandLoaderTest.php b/projects/packages/changelogger/tests/php/tests/src/CommandLoaderTest.php index 38c70acb22d42..507dc42f9cefc 100644 --- a/projects/packages/changelogger/tests/php/tests/src/CommandLoaderTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/CommandLoaderTest.php @@ -17,7 +17,6 @@ * @covers \Automattic\Jetpack\Changelogger\CommandLoader */ class CommandLoaderTest extends TestCase { - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Test `has()`. diff --git a/projects/packages/changelogger/tests/php/tests/src/ConfigTest.php b/projects/packages/changelogger/tests/php/tests/src/ConfigTest.php index bad68125c9839..6f402b916e81c 100644 --- a/projects/packages/changelogger/tests/php/tests/src/ConfigTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/ConfigTest.php @@ -18,7 +18,6 @@ * @covers \Automattic\Jetpack\Changelogger\Config */ class ConfigTest extends TestCase { - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Set up. diff --git a/projects/packages/changelogger/tests/php/tests/src/Plugins/SemverVersioningTest.php b/projects/packages/changelogger/tests/php/tests/src/Plugins/SemverVersioningTest.php index 56e41aa756481..889dbbfbff1f1 100644 --- a/projects/packages/changelogger/tests/php/tests/src/Plugins/SemverVersioningTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/Plugins/SemverVersioningTest.php @@ -21,7 +21,6 @@ */ class SemverVersioningTest extends TestCase { use \Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Test parseVersion and normalizeVersion. @@ -46,7 +45,7 @@ public function testParseVersion( $version, $expect, $normalized = null ) { /** * Data provider for testParseVersion. */ - public function provideParseVersion() { + public static function provideParseVersion() { return array( array( '1.2.3', @@ -199,7 +198,7 @@ public function testNormalizeVersion( $version, $expect, $extra = array() ) { /** * Data provider for testNormalizeVersion. */ - public function provideNormalizeVersion() { + public static function provideNormalizeVersion() { return array( 'add prerelease = alpha' => array( '1.2.3', @@ -278,7 +277,7 @@ public function testNextVersion( $version, array $changes, array $extra, $expect /** * Data provider for testNextVersion. */ - public function provideNextVersion() { + public static function provideNextVersion() { return array( 'No changes' => array( '1.2.3', @@ -427,7 +426,7 @@ public function testCompareVersions( $a, $expect, $b ) { /** * Data provider for testCompareVersions. */ - public function provideCompareVersions() { + public static function provideCompareVersions() { return array( array( '1.0.0', '==', '1.0.0' ), array( '1.0.0', '<', '2.0.0' ), @@ -477,7 +476,7 @@ public function testFirstVersion( array $extra, $expect ) { /** * Data provider for testFirstVersion. */ - public function provideFirstVersion() { + public static function provideFirstVersion() { return array( 'Normal' => array( array(), diff --git a/projects/packages/changelogger/tests/php/tests/src/Plugins/WordpressVersioningTest.php b/projects/packages/changelogger/tests/php/tests/src/Plugins/WordpressVersioningTest.php index d4add25c9524b..b457efa70b2eb 100644 --- a/projects/packages/changelogger/tests/php/tests/src/Plugins/WordpressVersioningTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/Plugins/WordpressVersioningTest.php @@ -23,7 +23,6 @@ */ class WordpressVersioningTest extends TestCase { use \Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Test getOptions. @@ -60,7 +59,7 @@ public function testParseVersion( $version, $expect, $normalized = null ) { /** * Data provider for testParseVersion. */ - public function provideParseVersion() { + public static function provideParseVersion() { return array( array( '1.2', @@ -289,7 +288,7 @@ public function testNormalizeVersion( $version, $expect, $extra = array() ) { /** * Data provider for testNormalizeVersion. */ - public function provideNormalizeVersion() { + public static function provideNormalizeVersion() { return array( 'add prerelease = alpha' => array( '1.2', @@ -367,7 +366,7 @@ public function testNextVersion( $version, array $changes, array $extra, $expect /** * Data provider for testNextVersion. */ - public function provideNextVersion() { + public static function provideNextVersion() { return array( 'No changes' => array( '1.2.3', @@ -494,7 +493,7 @@ public function testCompareVersions( $a, $expect, $b ) { /** * Data provider for testCompareVersions. */ - public function provideCompareVersions() { + public static function provideCompareVersions() { return array( array( '1.0', '==', '1.0' ), array( '1.0.0', '==', '1.0' ), @@ -546,7 +545,7 @@ public function testFirstVersion( array $extra, $expect ) { /** * Data provider for testFirstVersion. */ - public function provideFirstVersion() { + public static function provideFirstVersion() { return array( 'Normal' => array( array(), diff --git a/projects/packages/changelogger/tests/php/tests/src/SquashCommandTest.php b/projects/packages/changelogger/tests/php/tests/src/SquashCommandTest.php index d71e40982ae89..b42c8324fe357 100644 --- a/projects/packages/changelogger/tests/php/tests/src/SquashCommandTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/SquashCommandTest.php @@ -84,7 +84,7 @@ public function testExecute( array $args, array $options, array $inputs, $expect /** * Data provider for testExecute. */ - public function provideExecute() { + public static function provideExecute() { return array( 'Normal run' => array( array(), diff --git a/projects/packages/changelogger/tests/php/tests/src/UtilsTest.php b/projects/packages/changelogger/tests/php/tests/src/UtilsTest.php index 956c2e5a22c6b..45212d5246d52 100644 --- a/projects/packages/changelogger/tests/php/tests/src/UtilsTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/UtilsTest.php @@ -28,7 +28,6 @@ class UtilsTest extends TestCase { use \Yoast\PHPUnitPolyfills\Polyfills\AssertIsType; use \Yoast\PHPUnitPolyfills\Polyfills\AssertObjectProperty; use \Yoast\PHPUnitPolyfills\Polyfills\AssertionRenames; - use \Yoast\PHPUnitPolyfills\Polyfills\ExpectException; /** * Test runCommand. @@ -64,7 +63,7 @@ public function testRunCommand( $cmd, $options, $expectExitCode, $expectStdout, /** * Data provider for testRunCommand. */ - public function provideRunCommand() { + public static function provideRunCommand() { $tmp = realpath( sys_get_temp_dir() ); return array( @@ -178,7 +177,7 @@ public function testLoadChangeFile( $contents, $expect, $expectDiagnostics = arr /** * Data provider for testLoadChangeFile. */ - public function provideLoadChangeFile() { + public static function provideLoadChangeFile() { $ex = function ( $msg, $line ) { $ret = new LoadChangeFileException( $msg ); $ret->fileLine = $line; @@ -367,6 +366,7 @@ public function testGetRepoData() { array( 'mustRun' => true, 'env' => array( + 'GIT_CONFIG_GLOBAL' => '/dev/null', 'GIT_AUTHOR_NAME' => 'Dummy', 'GIT_AUTHOR_EMAIL' => 'dummy@example.com', 'GIT_AUTHOR_DATE' => '2021-01-01T11:11:11Z', diff --git a/projects/packages/changelogger/tests/php/tests/src/ValidateCommandTest.php b/projects/packages/changelogger/tests/php/tests/src/ValidateCommandTest.php index a063090b05d5f..eed127a367466 100644 --- a/projects/packages/changelogger/tests/php/tests/src/ValidateCommandTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/ValidateCommandTest.php @@ -73,7 +73,7 @@ public function testExecute( array $args, array $options, $expectExitCode, $expe /** * Data provider for testExecute. */ - public function provideExecute() { + public static function provideExecute() { $composerWithTypes = array( 'extra' => array( 'changelogger' => array( diff --git a/projects/packages/changelogger/tests/php/tests/src/VersionCommandTest.php b/projects/packages/changelogger/tests/php/tests/src/VersionCommandTest.php index 24eec243e8cd8..06ab232e9d740 100644 --- a/projects/packages/changelogger/tests/php/tests/src/VersionCommandTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/VersionCommandTest.php @@ -65,7 +65,7 @@ public function testExecute( array $args, array $options, $expectExitCode, $expe /** * Data provider for testExecute. */ - public function provideExecute() { + public static function provideExecute() { $changelog = "## 2.0.0 - 2021-02-22\n\n## 1.0.0 - 2021-02-21\n"; return array( diff --git a/projects/packages/changelogger/tests/php/tests/src/WriteCommandTest.php b/projects/packages/changelogger/tests/php/tests/src/WriteCommandTest.php index ca4df65b2eacf..6838e123f25ff 100644 --- a/projects/packages/changelogger/tests/php/tests/src/WriteCommandTest.php +++ b/projects/packages/changelogger/tests/php/tests/src/WriteCommandTest.php @@ -111,7 +111,7 @@ public function testExecute( array $args, array $options, array $inputs, $expect /** * Data provider for testExecute. */ - public function provideExecute() { + public static function provideExecute() { $date = gmdate( 'Y-m-d' ); return array(