Skip to content

Commit

Permalink
Use new consolidated constant for minimum PHP version
Browse files Browse the repository at this point in the history
  • Loading branch information
agh1 committed Mar 11, 2020
1 parent 36a21ed commit 8f13fca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 3 additions & 5 deletions civicrm.module
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ define('CIVICRM_UF_HEAD', TRUE);
/**
* Minimum required PHP
*
* Note: This duplicates CRM_Upgrade_Form::MINIMUM_PHP_VERSION. The
* duplication helps avoid a dependency-loop. (Reading `Form::MINIMUM_PHP_VERSION`
* requires loading `civicrm.settings.php`, but that triggers a parse-error
* on PHP 5.x.)
* Note: This duplicates CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER.
* The duplication helps avoid a dependency-loop.
*
* @see CRM_Upgrade_Form::MINIMUM_PHP_VERSION
* @see CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER
* @see CiviDrupal\PhpVersionTest::testConstantMatch()
*/
define('CIVICRM_DRUPAL_PHP_MINIMUM', '7.1.0');
Expand Down
10 changes: 6 additions & 4 deletions tests/phpunit/CiviDrupal/PhpVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,30 @@
class PhpVersionTest extends \PHPUnit\Framework\TestCase implements EndToEndInterface {

/**
* CIVICRM_DRUPAL_PHP_MINIMUM (civicrm.module) should match MINIMUM_PHP_VERSION (CRM/Upgrade/Form.php).
* CIVICRM_DRUPAL_PHP_MINIMUM (civicrm.module) should match
* CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER.
*/
public function testConstantMatch() {
$constantFile = $this->getDrupalModulePath() . '/civicrm.module';
$this->assertFileExists($constantFile);
$content = file_get_contents($constantFile);
if (preg_match(";define\\('CIVICRM_DRUPAL_PHP_MINIMUM', '(.*)'\\);", $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_DRUPAL_PHP_MINIMUM in ' . $constantFile);
}
}

/**
* "php" requirement (civicrm.info) should match MINIMUM_PHP_VERSION (CRM/Upgrade/Form.php).
* "php" requirement (civicrm.info) should match
* CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER.
*/
public function testInfoMatch() {
$infoFile = $this->getDrupalModulePath() . '/civicrm.info';
$this->assertFileExists($infoFile);
$info = drupal_parse_info_file($infoFile);
$expectMajorMinor = preg_replace(';^(\d+\.\d+)\..*$;', '\1', \CRM_Upgrade_Form::MINIMUM_PHP_VERSION);
$expectMajorMinor = preg_replace(';^(\d+\.\d+)\..*$;', '\1', \CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER);
$this->assertEquals($expectMajorMinor, $info['php']);
}

Expand Down

0 comments on commit 8f13fca

Please sign in to comment.