/**
  * @expectedException \AdammBalogh\KeyValueStore\Exception\InternalException
  */
 public function testFlushWithNotReadableDatabase()
 {
     $flintstoneDb = Flintstone::load('okke', ['dir' => vfsStream::url('root')]);
     $kvs = new KeyValueStore(new FileAdapter($flintstoneDb));
     chmod(vfsStream::url('root/okke.dat'), 0500);
     $kvs->flush();
 }
 public static function getProvider($type, $params, $accessTokenParams = [])
 {
     $provider = new Pdffiller($params);
     $tz = 'America/New_York';
     $kvs = new KeyValueStore(new FileAdapter(Flintstone::load('usersDatabase', ['dir' => '/tmp'])));
     $accessTokenKey = 'access_token';
     if (!$kvs->has($accessTokenKey)) {
         $accessToken = $provider->getAccessToken(self::$names[$type], $accessTokenParams);
         $liveTimeInSec = Carbon::createFromTimestamp($accessToken->getExpires(), $tz)->diffInSeconds(Carbon::now($tz));
         $kvs->set($accessTokenKey, $accessToken->getToken());
         $kvs->expire($accessTokenKey, $liveTimeInSec);
         $accessTokenString = $accessToken->getToken();
     } else {
         $accessTokenString = $kvs->get($accessTokenKey);
     }
     $provider->setAccessTokenHash($accessTokenString);
     return $provider;
 }
Exemplo n.º 3
0
 /**
  * Run the feature test multiple times with different options
  *
  * @param \PHPUnit_Framework_TestResult $result
  *
  * @return \PHPUnit_Framework_TestResult
  */
 public function run(\PHPUnit_Framework_TestResult $result = null)
 {
     if ($result === null) {
         $result = $this->createResult();
     }
     // Default options
     $this->db = Flintstone::load($this->dbName, array('dir' => __DIR__));
     $result->run($this);
     // With no cache
     $this->db = Flintstone::load($this->dbName, array('dir' => __DIR__, 'cache' => false, 'gzip' => false, 'ext' => 'txt'));
     $result->run($this);
     // With no cache and gzip compression
     $this->db = Flintstone::load($this->dbName, array('dir' => __DIR__, 'cache' => false, 'gzip' => true, 'ext' => 'txt'));
     $result->run($this);
     // With gzip compression and cache
     $this->db = Flintstone::load($this->dbName, array('dir' => __DIR__, 'cache' => true, 'gzip' => true, 'swap_memory_limit' => 0));
     $result->run($this);
     // With JSON formatter
     $this->db = Flintstone::load($this->dbName, array('dir' => __DIR__, 'cache' => false, 'formatter' => new JsonFormatter()));
     $result->run($this);
     return $result;
 }
Exemplo n.º 4
0
 /**
  * Create Guzzle and Flintstone objects
  *
  * @param  integer   $appId    application App Store id
  * @param  integer   $maxPages max pages count to check
  * @throws Exception when DB directory is not writable
  */
 public function __construct($appId, $maxPages = 3)
 {
     $this->appId = intval($appId);
     $this->maxPages = max(1, intval($maxPages));
     $this->client = new Guzzle(['defaults' => ['timeout' => 20, 'connect_timeout' => 10]]);
     $databaseDir = realpath(__DIR__ . '/..') . '/storage';
     if (!realpath($databaseDir) || !is_dir($databaseDir) || !is_writable($databaseDir)) {
         throw new Exception("Please make '{$databaseDir}' dir writable");
     }
     if (!file_exists($databaseDir . '/reviews.dat')) {
         $this->firstTime = true;
     }
     try {
         $this->storage = Flintstone::load('reviews', ['dir' => $databaseDir]);
     } catch (FlintstoneException $e) {
         $this->initException = $e;
     }
 }
 public function setUp()
 {
     $this->flintstoneDb = Flintstone::load('testDb', ['dir' => vfsStream::url('root')]);
     $this->kvs = new KeyValueStore(new FileAdapter($this->flintstoneDb));
 }