Test plugin meta data and version number consistency.#364
Merged
Conversation
c7dde3d to
b77e044
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds PHPUnit coverage to enforce WordPress plugin header/version consistency across readme.txt, the main plugin file, and package metadata, with small header tweaks to satisfy the new rules.
Changes:
- Introduces new unit tests to validate required/forbidden plugin/readme headers and ensure shared headers match.
- Adds unit tests to assert version consistency between
PODCASTING_VERSION,readme.txtstable tag, and Node package metadata. - Updates plugin/readme header fields (move “Requires PHP” to
readme.txt, normalize license string/URL).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 14 comments.
| File | Description |
|---|---|
| tests/unit/test-plugin-version.php | New tests ensuring the plugin version is consistent across PHP constant, readme stable tag, and package files. |
| tests/unit/test-plugin-headers.php | New tests enforcing required/forbidden headers and header parity between readme.txt and the plugin file; includes banner asset checks. |
| simple-podcasting.php | Normalizes plugin header license string and removes Requires PHP from the plugin header. |
| readme.txt | Adds Requires PHP and updates license URL to HTTPS for consistency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * This uses regex rather than including the plugin file to avoid side effects | ||
| * caused by the use of mocks for the test suite. | ||
| */ | ||
| $plugin_file_contents = file_get_contents( self::PLUGIN_ROOT_DIR . "/{$plugin_file_name}" ); |
| */ | ||
| public static function get_file_data( string $file, array $default_headers, $context = '' ): array { | ||
| // Pull only the first 8 KB of the file in. | ||
| $file_data = file_get_contents( $file, false, null, 0, 8 * 1024 ); |
Comment on lines
+137
to
+138
| $package_data = json_decode( file_get_contents( $package_file ), true ); | ||
| $this->assertSame( self::get_plugin_version_constant(), $package_data['version'], 'The version in package.json does not match the plugin version constant.' ); |
Comment on lines
+153
to
+155
| $package_lock_data = json_decode( file_get_contents( $package_lock_file ), true ); | ||
| $this->assertSame( self::get_plugin_version_constant(), $package_lock_data['version'], 'The version in package-lock.json does not match the plugin version constant.' ); | ||
| $this->assertSame( self::get_plugin_version_constant(), $package_lock_data['packages']['']['version'], "The packages['']['version'] in package-lock.json packages does not match the plugin version constant." ); |
Comment on lines
+178
to
+179
| $composer_data = json_decode( file_get_contents( $composer_file ), true ); | ||
| $this->assertArrayNotHasKey( 'version', $composer_data, 'The version key should not be present in composer.json.' ); |
| return array(); | ||
| } | ||
|
|
||
| $file_list = scandir( self::WP_ORG_ASSETS_DIR ); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
dkotter
approved these changes
Jun 22, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of the Change
Adds test suite for plugin headers and plugin version defintions to ensure they are correctly located for both the wordpress.org plugin repo and our preferences.
Copy-paste from https://github.com/peterwilsoncc/wp-plugin-template with a few mods for differing opinions and due to use of mocks in this test suite.
Includes a few changes to the headers to account for the following:
How to test the Change
No manual testing required, ensure the test suite passes.
Changelog Entry
Credits
Props @peterwilsoncc
Checklist: