Example #1
0
 /**
  * Check that least this version of PEAR package is present
  *
  * @param string Version number, required
  * @return $this
  * @see PearTest::testPearPackages()
  */
 public function atLeast($requiredVersion)
 {
     if (is_null($this->_package)) {
         $this->_failure("PEAR package is absent, can't compare versions");
         return $this;
     }
     $currentVersion = $this->_package->getVersion();
     if (version_compare($currentVersion, $requiredVersion, '>=')) {
         $this->_success("PEAR '{$this->_package->getName()}' package version is '{$currentVersion}'");
     } else {
         $this->_failure("PEAR '{$this->_package->getName()}' package version is '{$currentVersion}'" . ", but '{$requiredVersion}' is required");
     }
     return $this;
 }
Example #2
0
 /**
  * Validate version.
  *
  * @return void
  * @see exactly()
  * @see atLeast()
  */
 protected function _validateVersion($required, $comparison = '=')
 {
     if (is_null($this->_package)) {
         $this->_failure("PEAR package is absent, can't compare versions");
         return $this;
     }
     $currentVersion = $this->_package->getVersion();
     if (version_compare($currentVersion, $required, $comparison)) {
         $this->_success("PEAR '{$this->_package->getName()}' package version is '{$currentVersion}'");
     } else {
         $this->_failure(sprintf("PEAR '%s' package version is '%s', but '%s' is required (%s)", $this->_package->getName(), $currentVersion, $required, $comparison));
     }
     return $this;
 }