/** * Check if the current PHP version is greater than or equal to * PHP version 7. * * @param object $result an environment_results instance * @return bool result of version check */ function restrict_php_version_7(&$result) { return restrict_php_version($result, '7'); }
/** * Test the restrict_php_version() function returns false if the current * PHP version is less than the restricted version */ public function test_restrict_php_version_less_than_restricted_version() { global $CFG; require_once $CFG->libdir . '/environmentlib.php'; $result = new environment_results('php'); $delimiter = '.'; // Get the current PHP version. $currentversion = explode($delimiter, normalize_version(phpversion())); // Lets increase the major version to ensure don't trip the restriction. $currentversion[0]++; $restrictedversion = implode($delimiter, $currentversion); // Make sure the status is true before the test to see it flip to false. $result->setStatus(true); $this->assertFalse(restrict_php_version($result, $restrictedversion), 'restrict_php_version returns false if the current version is less than the restricted version'); }