Skip to content

Commit

Permalink
Consolidate to single constant for minimum PHP version
Browse files Browse the repository at this point in the history
  • Loading branch information
agh1 authored and bastienho committed Sep 10, 2020
1 parent 435994e commit 77dd7eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions civicrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@
/**
* Minimum required PHP
*
* Note: This duplicates CRM_Upgrade_Form::MINIMUM_PHP_VERSION. The
* duplication helps avoid dependency issues. (Reading `Form::MINIMUM_PHP_VERSION`
* requires loading `civicrm.settings.php`, but that triggers a parse-error
* Note: This duplicates CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER.
* The duplication helps avoid dependency issues. (Reading
* `CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER` requires loading
* `civicrm.settings.php`, but that triggers a parse-error
* on PHP 5.x.)
*
* @see CRM_Upgrade_Form::MINIMUM_PHP_VERSION
* @see CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER
* @see CiviWP\PhpVersionTest::testConstantMatch()
*/
define( 'CIVICRM_WP_PHP_MINIMUM', '7.1.0' );
Expand Down
5 changes: 3 additions & 2 deletions tests/phpunit/CiviWP/PhpVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
class PhpVersionTest extends \PHPUnit\Framework\TestCase implements EndToEndInterface {

/**
* CIVICRM_WP_PHP_MINIMUM (civicrm.module) should match MINIMUM_PHP_VERSION (CRM/Upgrade/Form.php).
* CIVICRM_WP_PHP_MINIMUM (civicrm.module) should match
* CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER.
*
* The literal value should be duplicated in the define() to prevent dependency issues.
*/
Expand All @@ -16,7 +17,7 @@ public function testConstantMatch() {
$this->assertFileExists($constantFile);
$content = file_get_contents($constantFile);
if (preg_match(";define\\(\\s*'CIVICRM_WP_PHP_MINIMUM'\\s*,\\s*'(.*)'\\s*\\);", $content, $m)) {
$this->assertEquals(\CRM_Upgrade_Form::MINIMUM_PHP_VERSION, $m[1]);
$this->assertEquals(\CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER, $m[1]);
}
else {
$this->fail('Failed to find CIVICRM_WP_PHP_MINIMUM in ' . $constantFile);
Expand Down

0 comments on commit 77dd7eb

Please sign in to comment.