Exemplo n.º 1
0
 public function testPutData()
 {
     $data = ['s' => 4.5895, 'e' => 137.4417];
     $this->file_cache->putData($this->test_file_name, $data);
     $file_name = $this->getFileName();
     $contents = file_get_contents($file_name);
     $this->assertEquals($contents, json_encode($data));
 }
Exemplo n.º 2
0
/**
 * Retrieves current version number from repository and saves it to the cache
 *
 * @return string The version number
 */
function checkCurrentVersion()
{
    $request = new Request();
    $url = 'https://api.github.com/repos/pantheon-systems/terminus/releases';
    $url .= '?per_page=1';
    $response = $request->simpleRequest($url, ['absolute_url' => true]);
    $release = array_shift($response['data']);
    $cache = new FileCache();
    $cache->putData('latest_release', ['version' => $release->name, 'check_date' => time()]);
    return $release->name;
}
Exemplo n.º 3
0
 /**
  * @vcr utils#checkCurrentVersion
  */
 public function testCheckForUpdate()
 {
     $log_file = getLogFileName();
     setOutputDestination($log_file);
     $cache = new FileCache();
     $cache->putData('latest_release', ['check_date' => strtotime('8 days ago')]);
     Utils\checkForUpdate(getLogger());
     $file_contents = explode("\n", file_get_contents($log_file));
     $this->assertFalse(strpos(array_pop($file_contents), 'An update to Terminus is available.'));
     resetOutputDestination($log_file);
 }
Exemplo n.º 4
0
 /**
  * Removes a site from the sites cache
  *
  * @param string $sitename Name of site to remove from array
  * @return void
  */
 public function remove($sitename)
 {
     $cache = (array) $this->cache->getData($this->cachekey, array('decode_array' => true));
     unset($cache[$sitename]);
     $this->cache->putData($this->cachekey, $cache);
 }
Exemplo n.º 5
0
 /**
  * Saves session data to cache
  *
  * @param array $data Session data to save
  * @return void|bool
  */
 public static function setData($data)
 {
     if (empty($data)) {
         return false;
     }
     $cache = new FileCache();
     $cache->putData('session', $data);
     $session = self::instance();
     $session->set('data', $data);
     foreach ($data as $k => $v) {
         $session->set($k, $v);
     }
     return true;
 }