Skip to content

Test plugin meta data and version number consistency.#364

Merged
dkotter merged 11 commits into
developfrom
test-plugin-meta
Jun 22, 2026
Merged

Test plugin meta data and version number consistency.#364
dkotter merged 11 commits into
developfrom
test-plugin-meta

Conversation

@peterwilsoncc

@peterwilsoncc peterwilsoncc commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

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:

  • Allow out of release cycle minimum requirements
  • License string and URL consistency in the two files.

How to test the Change

No manual testing required, ensure the test suite passes.

Changelog Entry

Developer - Introduce tests for the plugin meta data.

Credits

Props @peterwilsoncc

Checklist:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.txt stable 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 );
Comment thread tests/unit/test-plugin-version.php Outdated
Comment thread tests/unit/test-plugin-version.php Outdated
Comment thread tests/unit/test-plugin-headers.php Outdated
Comment thread readme.txt
peterwilsoncc and others added 3 commits June 19, 2026 12:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@peterwilsoncc peterwilsoncc marked this pull request as ready for review June 19, 2026 02:28
@peterwilsoncc peterwilsoncc requested a review from a team as a code owner June 19, 2026 02:28
@peterwilsoncc peterwilsoncc requested review from dkotter and removed request for a team June 19, 2026 02:28
@peterwilsoncc peterwilsoncc mentioned this pull request Jun 19, 2026
15 tasks
@dkotter dkotter added this to the 2.0.0 milestone Jun 22, 2026
@dkotter dkotter merged commit 14ee59c into develop Jun 22, 2026
15 checks passed
@dkotter dkotter deleted the test-plugin-meta branch June 22, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants