forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update minimum required version in PHP. (WordPress#65301)
* Update minimum required version in PHP. * Use a constant. * Test plugin meta data and constant match. * Set constant incorrectly to demonstrate failing tests. * Use regex to extract the constant. * Match the version in the constant and plugin meta. Co-authored-by: peterwilsoncc <[email protected]> Co-authored-by: Mamaduka <[email protected]>
- Loading branch information
1 parent
b0abc74
commit 9e88d86
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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,26 @@ | ||
<?php | ||
/** | ||
* Unit tests covering the version checks in the plugin file. | ||
* | ||
* @package Gutenberg | ||
*/ | ||
class Test_PluginMetaData_Test extends WP_UnitTestCase { | ||
/** | ||
* Test the minimum WordPress version check. | ||
* | ||
* Ensures the constant defined as the minimum required version of WordPress | ||
* matches the minimum version defined in the plugin header. | ||
*/ | ||
public function test_minimum_required_wordpress_version() { | ||
$file_meta = get_file_data( __DIR__ . '/../gutenberg.php', array( 'RequiresWP' => 'Requires at least' ) ); | ||
/* | ||
* Gutenberg.php isn't loaded in the test environment. | ||
* | ||
* Read the file directly and use regex to extract the constant. | ||
*/ | ||
preg_match( '/GUTENBERG_MINIMUM_WP_VERSION\', \'(.*?)\'/', file_get_contents( __DIR__ . '/../gutenberg.php' ), $matches ); | ||
$version_in_file = $matches[1]; | ||
|
||
$this->assertSame( $file_meta['RequiresWP'], $version_in_file, 'The minimum required WordPress version does not match the plugin header.' ); | ||
} | ||
} |