Example #1
0
 public function testFetchLatestZENDVersion()
 {
     if (!constant('TESTS_ZEND_VERSION_ONLINE_ENABLED')) {
         $this->markTestSkipped('Version online tests are not enabled');
     }
     if (!extension_loaded('openssl')) {
         $this->markTestSkipped('This test requires openssl extension to be enabled in PHP');
     }
     $actual = Version::getLatest('ZEND');
     $this->assertRegExp('/^[1-2](\\.[0-9]+){2}/', $actual);
 }
Example #2
0
 /**
  * This is the "about" action. It is used to display the "About" page.
  * @return \Zend\View\Model\ViewModel
  */
 public function aboutAction()
 {
     // Get current ZF version
     $zendFrameworkVer = Version::VERSION;
     // Fetch the latest available version of ZF
     $latestVer = Version::getLatest();
     // Test if newer version is available
     $isNewerVerAvailable = Version::compareVersion($latestVer);
     // Return variables to view script with the help of
     // ViewObject variable container
     return new ViewModel(array('zendFrameworkVer' => $zendFrameworkVer, 'isNewerVerAvailable' => $isNewerVerAvailable, 'latestVer' => $latestVer));
 }
Example #3
0
 public function _after(\Codeception\TestCase $test)
 {
     $_SESSION = array();
     $_GET = array();
     $_POST = array();
     $_COOKIE = array();
     // reset singleton
     StaticEventManager::resetInstance();
     // Reset singleton placeholder if version < 2.2.0, no longer required in 2.2.0+
     if (Version::compareVersion('2.2.0') >= 0) {
         Placeholder\Registry::unsetRegistry();
     }
     $this->queries = 0;
     $this->time = 0;
 }
Example #4
0
 public function _after(\Codeception\TestCase $test)
 {
     $_SESSION = [];
     $_GET = [];
     $_POST = [];
     $_COOKIE = [];
     // reset singleton
     StaticEventManager::resetInstance();
     // Reset singleton placeholder if version < 2.2.0, no longer required in 2.2.0+
     if (Version::compareVersion('2.2.0') >= 0) {
         Placeholder\Registry::unsetRegistry();
     }
     //Close the session, if any are open
     if (session_status() == PHP_SESSION_ACTIVE) {
         session_write_close();
     }
     $this->queries = 0;
     $this->time = 0;
 }
Example #5
0
 /**
  * Wrapper for Zend\Version::getLatest with caching functionality, so that
  * ZendDeveloperTools won't act as a "DDoS bot-network".
  *
  * @param  string $currentVersion
  * @return array
  */
 protected function getLatestVersion($currentVersion)
 {
     if (!$this->options->isVersionCheckEnabled()) {
         return array(true, '');
     }
     $cacheDir = $this->options->getCacheDir();
     // exit early if the cache dir doesn't exist,
     // to prevent hitting the GitHub API for every request.
     if (!is_dir($cacheDir)) {
         return array(true, '');
     }
     if (file_exists($cacheDir . '/ZDT_ZF_Version.cache')) {
         $cache = file_get_contents($cacheDir . '/ZDT_ZF_Version.cache');
         $cache = explode('|', $cache);
         if ($cache[0] + self::VERSION_CACHE_TTL > time()) {
             // the cache file was written before the version was upgraded.
             if ($currentVersion === $cache[2] || $cache[2] === 'N/A') {
                 return array(true, '');
             }
             return array($cache[1] === 'yes' ? true : false, $cache[2]);
         }
     }
     $isLatest = Version::isLatest();
     $latest = Version::getLatest();
     file_put_contents($cacheDir . '/ZDT_ZF_Version.cache', sprintf('%d|%s|%s', time(), $isLatest ? 'yes' : 'no', $latest === null ? 'N/A' : $latest));
     return array($isLatest, $latest);
 }
    $result = TEST_FAIL;
    $failed = true;
}
Helper::printLineToc($counter, 'Checking HTTPS stream wrapper', $result);
$counter++;
// -----------------------------------------------------------------------------
if (true === method_exists('\\Zend\\Debug\\Debug', 'dump')) {
    $result = TEST_PASS;
} else {
    $result = TEST_FAIL;
    $failed = true;
}
Helper::printLineToc($counter, 'Checking Zend Framework path', $result);
$counter++;
// -----------------------------------------------------------------------------
if (1 === Version::compareVersion(PHP_VERSION, MIN_PHP_VERSION)) {
    $result = TEST_PASS;
} else {
    $result = TEST_FAIL;
    $failed = true;
}
Helper::printLineToc($counter, sprintf('Checking Zend Framework version (%s)', Version::VERSION), $result);
$counter++;
// -----------------------------------------------------------------------------
if (extension_loaded('openssl')) {
    $version = OPENSSL_VERSION_TEXT;
    $result = TEST_PASS;
} else {
    $version = 'N/A';
    $result = TEST_FAIL;
    $failed = true;
Example #7
0
 /**
  * Run in separate process to avoid Version::$latestParameter caching
  *
  * @runInSeparateProcess
  */
 public function testFetchLatestVersionDoesNotThrowZendHttpClientException()
 {
     if (!constant('TESTS_ZEND_VERSION_ONLINE_ENABLED')) {
         $this->markTestSkipped('Version online tests are not enabled');
     }
     if (!extension_loaded('openssl')) {
         $this->markTestSkipped('This test requires openssl extension to be enabled in PHP');
     }
     $httpClient = new Http\Client('http://example.com', array('sslcapath' => '/dev/null', 'sslverifypeer' => true));
     $actual = Version::getLatest(Version::VERSION_SERVICE_GITHUB, $httpClient);
     $this->assertEquals('not available', $actual);
 }