Repository navigation
Plugin Directory: Warn about invalid Requires plugin headers on import #1196
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
Open
obenland
wants to merge
3
commits into
WordPress:trunk
Choose a base branch
from
obenland:fix/requires-plugin-header-warnings
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
7d51973
Plugin Directory: Warn about invalid Requires plugin headers on import
obenland 90e37c3
Plugin Directory: Round the trunk version in the Requires header check
obenland 1ee8638
Plugin Directory: Round the trunk version in the readme Requires at l…
obenland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...c_html/wp-content/plugins/plugin-directory/tests/Import_Requires_Header_Warnings_Test.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| <?php | ||
| /** | ||
| * Tests for Import::requires_header_warnings(). | ||
| * | ||
| * @package WordPressdotorg\Plugin_Directory\Tests | ||
| */ | ||
|
|
||
| declare( strict_types = 1 ); | ||
|
|
||
| use PHPUnit\Framework\Attributes\DataProvider; | ||
| use PHPUnit\Framework\Attributes\Group; | ||
| use PHPUnit\Framework\TestCase; | ||
| use WordPressdotorg\Plugin_Directory\CLI\Import; | ||
|
|
||
| /** | ||
| * Covers the import warnings for the Requires at least and Requires PHP plugin headers. | ||
| * | ||
| * @group import | ||
| */ | ||
| #[Group( 'import' )] | ||
| class Import_Requires_Header_Warnings_Test extends TestCase { | ||
|
|
||
| /** | ||
| * The plugin headers are checked on their own and against the readme. | ||
| * | ||
| * @dataProvider headers_provider | ||
| * | ||
| * @param array $headers The RequiresWP and RequiresPHP plugin headers. | ||
| * @param array $readme The readme's requires and requires_php fields. | ||
| * @param array $expected The expected warnings. | ||
| * @return void | ||
| */ | ||
| #[DataProvider( 'headers_provider' )] | ||
| public function test_requires_header_warnings( array $headers, array $readme, array $expected ): void { | ||
| $this->assertSame( $expected, Import::requires_header_warnings( (object) $headers, (object) $readme ) ); | ||
| } | ||
|
|
||
| /** | ||
| * Supplies plugin headers, readme fields, and the warnings they should produce. | ||
| * | ||
| * @return array<string, array<int, array>> | ||
| */ | ||
| public static function headers_provider(): array { | ||
| return array( | ||
| 'matching, with trailing .0' => array( | ||
| array( | ||
| 'RequiresWP' => '6.0', | ||
| 'RequiresPHP' => '7.4', | ||
| ), | ||
| array( | ||
| 'requires' => '6.0.0', | ||
| 'requires_php' => '7.4', | ||
| ), | ||
| array(), | ||
| ), | ||
| 'no readme fields to compare' => array( | ||
| array( | ||
| 'RequiresWP' => '6.0', | ||
| 'RequiresPHP' => '7.4', | ||
| ), | ||
| array( | ||
| 'requires' => '', | ||
| 'requires_php' => '', | ||
| ), | ||
| array(), | ||
| ), | ||
| 'header newer than trunk' => array( | ||
| array( | ||
| 'RequiresWP' => '99.0', | ||
| 'RequiresPHP' => '', | ||
| ), | ||
| array( | ||
| 'requires' => '6.0', | ||
| 'requires_php' => '', | ||
| ), | ||
| array( 'plugin_requires_header_invalid' => '99.0' ), | ||
| ), | ||
| 'headers not versions' => array( | ||
| array( | ||
| 'RequiresWP' => '6.0-beta', | ||
| 'RequiresPHP' => '8', | ||
| ), | ||
| array( | ||
| 'requires' => '', | ||
| 'requires_php' => '', | ||
| ), | ||
| array( | ||
| 'plugin_requires_header_invalid' => '6.0-beta', | ||
| 'plugin_requires_php_header_invalid' => '8', | ||
| ), | ||
| ), | ||
| 'headers differ from readme' => array( | ||
| array( | ||
| 'RequiresWP' => '6.2', | ||
| 'RequiresPHP' => '8.0', | ||
| ), | ||
| array( | ||
| 'requires' => '6.0', | ||
| 'requires_php' => '7.4', | ||
| ), | ||
| array( | ||
| 'requires_header_mismatch' => array( | ||
| 'plugin' => '6.2', | ||
| 'readme' => '6.0', | ||
| ), | ||
| 'requires_php_header_mismatch' => array( | ||
| 'plugin' => '8.0', | ||
| 'readme' => '7.4', | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.