Add test to catch missing version updates.

This commit is contained in:
Jeff Stieler 2019-06-13 15:40:02 -06:00
parent 241ebb63ff
commit d4e242b028
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
/**
* Plugin Version Tests
*
* @package WooCommerce\Tests\Reports
* @since 3.6.4
*/
/**
* Plugin Version Tests Class
*
* @package WooCommerce\Tests\Reports
* @since 3.6.4
*/
class WC_Admin_Tests_Plugin_Version extends WP_UnitTestCase {
/**
* Ensure that all version numbers match.
*/
public function test_version_numbers() {
// Get package.json version.
$package_json = file_get_contents( 'package.json' );
$package = json_decode( $package_json );
// Get main plugin file header version.
$plugin = get_file_data( 'woocommerce-admin.php', array( 'Version' => 'Version' ) );
// Get plugin DB version.
$db_version = defined( 'WC_ADMIN_VERSION_NUMBER' ) ? constant( 'WC_ADMIN_VERSION_NUMBER' ) : false;
// Compare all versions to the package.json value.
$this->assertEquals( $package->version, $plugin['Version'], 'Plugin header version does not match package.json' );
$this->assertEquals( $package->version, $db_version, 'DB version constant does not match package.json' );
}
}