Example #1
0
 /**
  * @param $element
  *
  * @return Page
  */
 public function select($element)
 {
     $pageClass = $this->getPageClass($element);
     $element = $this->item($element);
     $this->debug("Clicking element {$element} (" . $element->getId() . ")\n");
     $element->click();
     return $this->driver->pageFactoryCreate($pageClass);
 }
Example #2
0
 public function testAuthenticationFails()
 {
     $email = '*****@*****.**';
     $password = 12345678;
     $this->auth->expects($this->once())->method('getAdapter')->will($this->returnValue($this->adapter));
     $this->auth->expects($this->once())->method('authenticate')->will($this->returnValue($this->getFailureResult()));
     $result = $this->authenticator->authenticate($email, $password);
     // Ensures identity and credential were actually set on the mock adapter
     $this->assertEquals($email, $this->adapter->getIdentity());
     $this->assertEquals($password, $this->adapter->getCredential());
     $this->assertFalse($result->isValid());
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function doFetch(array $ids)
 {
     $values = array();
     $now = time();
     foreach ($ids as $id) {
         $file = $this->getFile($id);
         if (!file_exists($file) || !($h = @fopen($file, 'rb'))) {
             continue;
         }
         if ($now >= (int) ($expiresAt = fgets($h))) {
             fclose($h);
             if (isset($expiresAt[0])) {
                 @unlink($file);
             }
         } else {
             $i = rawurldecode(rtrim(fgets($h)));
             $value = stream_get_contents($h);
             fclose($h);
             if ($i === $id) {
                 $values[$id] = parent::unserialize($value);
             }
         }
     }
     return $values;
 }
Example #4
0
 /**
  * Set dimensions
  *
  * @param  array  $dimensions
  * @param  string $unit
  *
  * @return void
  */
 public function setDimensions(array $dimensions, $unit = null)
 {
     parent::setDimensions($dimensions, $unit);
     if (null !== $unit && ($unit == 'IN' || $unit == 'CM')) {
         $this->dimensions['UnitOfMeasurement'] = $unit;
     }
 }
Example #5
0
 /**
  * Checks for allowed characters
  * @see Zend\Validator\Barcode.AbstractAdapter::checkChars()
  */
 public function hasValidCharacters($value)
 {
     if (strpbrk($value, 'ABCD')) {
         $first = $value[0];
         if (!strpbrk($first, 'ABCD')) {
             // Missing start char
             return false;
         }
         $last = substr($value, -1, 1);
         if (!strpbrk($last, 'ABCD')) {
             // Missing stop char
             return false;
         }
         $value = substr($value, 1, -1);
     } elseif (strpbrk($value, 'TN*E')) {
         $first = $value[0];
         if (!strpbrk($first, 'TN*E')) {
             // Missing start char
             return false;
         }
         $last = substr($value, -1, 1);
         if (!strpbrk($last, 'TN*E')) {
             // Missing stop char
             return false;
         }
         $value = substr($value, 1, -1);
     }
     $chars = $this->getCharacters();
     $this->setCharacters('0123456789-$:/.+');
     $result = parent::hasValidCharacters($value);
     $this->setCharacters($chars);
     return $result;
 }
Example #6
0
    /**
     * Checks for allowed characters
     * @see Zend\Validator\Barcode.AbstractAdapter::checkChars()
     */
    public function checkChars($value)
    {
        $first = $value[0];
        if (strpbrk($value, 'ABCD') !== false) {
            $first = $value[0];
            if (strpbrk($first, 'ABCD') === false) {
                // Missing start char
                return false;
            }

            $last = substr($value, -1, 1);
            if (strpbrk($last, 'ABCD') === false) {
                // Missing stop char
                return false;
            }

            $value = substr($value, 1, -1);
        }

        $chars             = $this->_characters;
        $this->_characters = '0123456789-$:/.+';
        $result            = parent::checkChars($value);
        $this->_characters = $chars;
        return $result;
    }
Example #7
0
 /**
  * Constructor
  *
  * Instantiate the cache db object
  *
  * @param  string  $db
  * @param  int     $lifetime
  * @param  string  $table
  * @param  boolean $pdo
  * @throws Exception
  * @return Sqlite
  */
 public function __construct($db, $lifetime = 0, $table = 'pop_cache', $pdo = false)
 {
     parent::__construct($lifetime);
     $this->setDb($db);
     $pdoDrivers = class_exists('Pdo', false) ? \PDO::getAvailableDrivers() : [];
     if (!class_exists('Sqlite3', false) && !in_array('sqlite', $pdoDrivers)) {
         throw new Exception('Error: SQLite is not available.');
     } else {
         if ($pdo && !in_array('sqlite', $pdoDrivers)) {
             $pdo = false;
         } else {
             if (!$pdo && !class_exists('Sqlite3', false)) {
                 $pdo = true;
             }
         }
     }
     if ($pdo) {
         $this->sqlite = new \PDO('sqlite:' . $this->db);
         $this->isPdo = true;
     } else {
         $this->sqlite = new \SQLite3($this->db);
     }
     if (null !== $table) {
         $this->setTable($table);
     }
 }
Example #8
0
 /**
  * Constructor
  *
  * Instantiate the APC cache object
  *
  * @param  int $lifetime
  * @throws Exception
  * @return Apc
  */
 public function __construct($lifetime = 0)
 {
     parent::__construct($lifetime);
     if (!function_exists('apc_cache_info')) {
         throw new Exception('Error: APC is not available.');
     }
     $this->info = apc_cache_info();
 }
Example #9
0
 /**
  * Overrides parent checkLength
  *
  * @param string $value Value
  * @return boolean
  */
 public function checkLength($value)
 {
     if (strlen($value) != 8) {
         $this->setCheck(false);
     } else {
         $this->setCheck(true);
     }
     return parent::checkLength($value);
 }
Example #10
0
 /**
  * Overrides parent checkLength
  *
  * @param string $value Value
  * @return bool
  */
 public function hasValidLength($value)
 {
     if (strlen($value) == 7) {
         $this->useChecksum(false);
     } else {
         $this->useChecksum(true);
     }
     return parent::hasValidLength($value);
 }
Example #11
0
 /**
  * Validates the checksum
  *
  * @param  string $value The barcode to check the checksum for
  * @return bool
  */
 public function hasValidChecksum($value)
 {
     if (strlen($value) == 8) {
         $this->setChecksum('issn');
     } else {
         $this->setChecksum('gtin');
     }
     return parent::hasValidChecksum($value);
 }
Example #12
0
 /**
  * Validates the checksum
  *
  * @param  string $value The barcode to check the checksum for
  * @return boolean
  */
 public function checksum($value)
 {
     if (strlen($value) == 8) {
         $this->_checksum = '_issn';
     } else {
         $this->_checksum = '_gtin';
     }
     return parent::checksum($value);
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function setOption($key, $value)
 {
     switch ($key) {
         case 'limit':
             $value = (int) $value;
             $this->limit = $value;
             return true;
     }
     return parent::setOption($key, $value);
 }
Example #14
0
 /**
  * Constructor
  *
  * Instantiate the cache session object
  *
  * @param  int $lifetime
  * @return Session
  */
 public function __construct($lifetime = 0)
 {
     parent::__construct($lifetime);
     if (session_id() == '') {
         session_start();
     }
     if (!isset($_SESSION['_POP_CACHE'])) {
         $_SESSION['_POP_CACHE'] = [];
     }
 }
Example #15
0
 public static function init(array $params)
 {
     parent::init($params);
     $redis = new \Redis();
     if (array_key_exists('socket', $params)) {
         $redis->connect($params['socket']);
     } else {
         $redis->connect($params['host'], $params['port']);
     }
     $redis->select($params['index']);
     self::$redis = $redis;
 }
Example #16
0
 /**
  * Constructor
  *
  * Instantiate the memcache cache object
  *
  * @param  int    $lifetime
  * @param  string $host
  * @param  int    $port
  * @throws Exception
  * @return Redis
  */
 public function __construct($lifetime = 0, $host = 'localhost', $port = 6379)
 {
     parent::__construct($lifetime);
     if (!class_exists('Redis', false)) {
         throw new Exception('Error: Redis is not available.');
     }
     $this->redis = new \Redis();
     if (!$this->redis->connect($host, (int) $port)) {
         throw new Exception('Error: Unable to connect to the memcached server.');
     }
     $this->version = $this->redis->info()['redis_version'];
 }
Example #17
0
 /**
  * Allows start and stop tag within checked chars
  *
  * @param  string $value The barcode to check for allowed characters
  * @return boolean
  */
 public function hasValidCharacters($value)
 {
     if ($value[0] == '(') {
         $value = substr($value, 1);
         if ($value[strlen($value) - 1] == ')') {
             $value = substr($value, 0, -1);
         } else {
             return false;
         }
     }
     return parent::hasValidCharacters($value);
 }
Example #18
0
 /**
  * Constructor
  *
  * Instantiate the memcache cache object
  *
  * @param  int    $lifetime
  * @param  string $host
  * @param  int    $port
  * @throws Exception
  * @return Memcache
  */
 public function __construct($lifetime = 0, $host = 'localhost', $port = 11211)
 {
     parent::__construct($lifetime);
     if (!class_exists('Memcache', false)) {
         throw new Exception('Error: Memcache is not available.');
     }
     $this->memcache = new \Memcache();
     if (!$this->memcache->connect($host, (int) $port)) {
         throw new Exception('Error: Unable to connect to the memcache server.');
     }
     $this->version = $this->memcache->getVersion();
 }
Example #19
0
 /**
  * Constructor
  *
  * Instantiate the memcached cache object
  *
  * @param  int    $lifetime
  * @param  string $host
  * @param  int    $port
  * @param  int    $weight
  * @throws Exception
  * @return Memcached
  */
 public function __construct($lifetime = 0, $host = 'localhost', $port = 11211, $weight = 1)
 {
     parent::__construct($lifetime);
     if (!class_exists('Memcached', false)) {
         throw new Exception('Error: Memcached is not available.');
     }
     $this->memcached = new \Memcached();
     $this->addServer($host, $port, $weight);
     $version = $this->memcached->getVersion();
     if (isset($version[$host . ':' . $port])) {
         $this->version = $version[$host . ':' . $port];
     }
 }
Example #20
0
 public function getItem($key, &$success = null, $queue = true)
 {
     //check to see if it's already been cached in the class
     $value = parent::getItem($key, $success, $queue);
     if ($success === true) {
         return $value;
     } else {
         $fileName = $this->getFileName($key);
         if ($queue === true && !file_exists($fileName)) {
             if ($this->isQueueInProgress($fileName) === true) {
                 //anonymous function to test if we should continue to wait
                 $condition = function () use($fileName) {
                     return !file_exists($fileName);
                 };
                 $wait = $this->wait($condition);
                 if ($wait === false) {
                     $this->clearQueue($key);
                     $success = false;
                     return null;
                 } else {
                     $success = true;
                     return $this->readFromFile($fileName);
                 }
             } else {
                 $this->queue($fileName);
                 $success = false;
                 return null;
             }
         } else {
             $ttl = $this->getTtl($key);
             if ($ttl < time() && $this->isReCacheInProgress($fileName) === false) {
                 //set the queue
                 $this->reCache($fileName);
                 $success = false;
                 return null;
             } else {
                 $success = true;
                 $value = $this->readFromFile($fileName);
                 return $value;
             }
         }
     }
 }
Example #21
0
 /**
  * @param array $params
  */
 public function __construct(array $params = array())
 {
     $this->ensureModuleExistence();
     parent::__construct($params);
 }
Example #22
0
 public function __construct($config)
 {
     parent::__construct($config);
     $this->socialFieldsMap = array('socialId' => 'id', 'email' => 'email', 'name' => 'name', 'socialPage' => 'link', 'sex' => 'gender', 'birthday' => 'birthday');
     $this->provider = 'facebook';
 }
Example #23
0
 /**
  * Set content. Remove start/end of comment block not allow in CoffeeScript
  *
  * @param string $content
  * @return $this
  */
 public function setContent($content)
 {
     $content = str_replace("/**\n", '', $content);
     $content = str_replace("\n */", '', $content);
     return parent::setContent($content);
 }
Example #24
0
 /**
  * Allows start and stop tag within checked chars
  *
  * @param  string $value The barcode to check for allowed characters
  * @return boolean
  */
 public function checkChars($value)
 {
     if ($value[0] == '(') {
         $value = substr($value, 1);
         if ($value[strlen($value) - 1] == ')') {
             $value = substr($value, 0, -1);
         } else {
             return false;
         }
     }
     return parent::checkChars($value);
 }
Example #25
0
 /**
  * {@inheritdoc}
  */
 public function __construct($imageFilename)
 {
     parent::__construct($imageFilename);
     $this->imagick = new \Imagick($this->getImageFileName());
 }
Example #26
0
 /**
  * Simple Query Output prior to Rendering
  *
  * @param   array $data
  * @param   array $model_registry
  *
  * @return  array
  * @since   1.0.0
  */
 public function escapeOutput(array $data = array(), array $model_registry = array())
 {
     $this->data = parent::escapeOutput($data, $model_registry);
     return $this->data;
 }
 public function __construct($namespace = '', $defaultLifetime = 0, $directory = null)
 {
     parent::__construct('', $defaultLifetime);
     $this->init($namespace, $directory);
 }
Example #28
0
 public function __construct($config)
 {
     parent::__construct($config);
     $this->socialFieldsMap = array('socialId' => 'uid', 'email' => 'email', 'name' => 'nick', 'socialPage' => 'link', 'avatar' => 'pic_big', 'birthday' => 'birthday');
     $this->provider = 'mailru';
 }
Example #29
0
 public function __construct($config)
 {
     parent::__construct($config);
     $this->socialFieldsMap = array('socialId' => 'id', 'email' => 'default_email', 'name' => 'real_name', 'socialPage' => 'link', 'avatar' => 'picture', 'sex' => 'sex', 'birthday' => 'birthday');
     $this->provider = 'yandex';
 }
Example #30
0
 public function __construct($config)
 {
     parent::__construct($config);
     $this->socialFieldsMap = array('socialId' => 'uid', 'email' => 'email', 'avatar' => 'photo_big', 'birthday' => 'bdate');
     $this->provider = 'vk';
 }