/** * Enter description here... * * @return \Zend\Service\SlideShare\SlideShare */ protected function _getSSObject() { $ss = new SlideShareService(TESTS_ZEND_SERVICE_SLIDESHARE_APIKEY, TESTS_ZEND_SERVICE_SLIDESHARE_SHAREDSECRET, TESTS_ZEND_SERVICE_SLIDESHARE_USERNAME, TESTS_ZEND_SERVICE_SLIDESHARE_PASSWORD, TESTS_ZEND_SERVICE_SLIDESHARE_SLIDESHOWID); $cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); $ss->setCacheObject($cache); return $ss; }
public function setUp() { $this->_originaltimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Paris'); $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); DateObjectTestHelper::setOptions(array('cache' => $this->_cache)); }
public function testAdapterFactory() { $adapter1 = Cache\StorageFactory::adapterFactory('Memory'); $this->assertInstanceOf('Zend\\Cache\\Storage\\Adapter\\Memory', $adapter1); $adapter2 = Cache\StorageFactory::adapterFactory('Memory'); $this->assertInstanceOf('Zend\\Cache\\Storage\\Adapter\\Memory', $adapter2); $this->assertNotSame($adapter1, $adapter2); }
/** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. * * @return void */ public function setUp() { $this->clearRegistry(); $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); Currency\Currency::setCache($this->_cache); $this->helper = new Helper\Currency('de_AT'); }
/** * @param string $apiKey * @param StorageInterface $cache */ public function __construct($apiKey, $service, StorageInterface $cache = null) { $this->apiKey = $apiKey; $this->service = $service; if ($cache === null) { $cache = StorageFactory::adapterFactory('memory ', array('ttl' => 600)); } $this->cache = $cache; }
protected function setUp() { $this->select = new Sql\Select(); $this->select->from('test'); $this->testCollection = range(1, 101); $this->paginator = new Paginator\Paginator(new Paginator\Adapter\ArrayAdapter($this->testCollection)); $this->config = Config\Factory::fromFile(__DIR__ . '/_files/config.xml', true); $this->cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); Paginator\Paginator::setCache($this->cache); $this->_restorePaginatorDefaults(); }
private function createAdapter($name) { $name = ucfirst(strtolower($name)); if ($name === self::ENGINE_FILE) { $name = self::ENGINE_FILESYSTEM; } $const = 'PHPPdf\\Cache\\CacheImpl::ENGINE_' . strtoupper($name); if (!defined($const)) { throw $this->cacheEngineDosntExistException($name); } $name = constant($const); return StorageFactory::adapterFactory($name); }
public function __construct($game) { $this->game = $game; // $this->mock = new MockHandler([]); $this->client = new HttpClient(); $adapter = new \Zend\Http\Client\Adapter\Curl(); $adapter->setCurlOption(CURLOPT_SSL_VERIFYPEER, false); $this->client->setAdapter($adapter); // $this->client = new Client([ // 'handler' => HandlerStack::create($this->mock) //]); $cache = StorageFactory::adapterFactory('memory ', array('ttl' => 100)); parent::__construct('5nssdkuvwub25ydqzhwwznvzh8hh2ag9', new Region(Region::EUROPE), $cache); }
protected function setUp() { if (!extension_loaded('pdo_sqlite')) { $this->markTestSkipped('Pdo_Sqlite extension is not loaded'); } $this->_adapter = new \Zend\Db\Adapter\Pdo\Sqlite(array('dbname' => __DIR__ . '/_files/test.sqlite')); $this->_query = $this->_adapter->select()->from('test'); $this->_testCollection = range(1, 101); $this->_paginator = Paginator\Paginator::factory($this->_testCollection); $this->_config = Config\Factory::fromFile(__DIR__ . '/_files/config.xml', true); $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); $this->_cache->clear(CacheAdapter::MATCH_ALL); Paginator\Paginator::setCache($this->_cache); $this->_restorePaginatorDefaults(); }
protected function setUp() { if (!extension_loaded('pdo_sqlite')) { $this->markTestSkipped('Pdo_Sqlite extension is not loaded'); } $this->_adapter = new DbAdapter\Adapter(array('driver' => 'Pdo_Sqlite', 'database' => __DIR__ . '/_files/test.sqlite')); $this->_query = new Sql\Select(); $this->_query->from('test'); $this->_testCollection = range(1, 101); $this->_paginator = Paginator\Paginator::factory($this->_testCollection); $this->_config = Config\Factory::fromFile(__DIR__ . '/_files/config.xml', true); $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); Paginator\Paginator::setCache($this->_cache); $this->_restorePaginatorDefaults(); }
public function __construct() { $this->tmpCacheDir = @tempnam(sys_get_temp_dir(), 'zend_cache_test_'); if (!$this->tmpCacheDir) { $err = error_get_last(); $this->fail("Can't create temporary cache directory-file: {$err['message']}"); } elseif (!@unlink($this->tmpCacheDir)) { $err = error_get_last(); $this->fail("Can't remove temporary cache directory-file: {$err['message']}"); } elseif (!@mkdir($this->tmpCacheDir, 0777)) { $err = error_get_last(); $this->fail("Can't create temporary cache directory: {$err['message']}"); } $this->storage = StorageFactory::adapterFactory('filesystem', ['cache_dir' => $this->tmpCacheDir]); parent::__construct(); }
public function setUp() { $this->_cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); }
public function testLoadingFilesIntoCacheAfterwards() { $cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); $this->assertFalse(Adapter\ArrayAdapter::hasCache()); Adapter\ArrayAdapter::setCache($cache); $this->assertTrue(Adapter\ArrayAdapter::hasCache()); $adapter = new Adapter\ArrayAdapter(__DIR__ . '/_files/translation_en.php', 'en'); $cache = Adapter\ArrayAdapter::getCache(); $this->assertTrue($cache instanceof CacheAdapter); $adapter->addTranslation(__DIR__ . '/_files/translation_en.php', 'ru', array('reload' => true)); $test = $adapter->getMessages('all'); $this->assertEquals(6, count($test['ru'])); }
public function testAdapterFactory() { $cache = Cache\StorageFactory::adapterFactory('Memory'); $this->assertInstanceOf('Zend\\Cache\\Storage\\Adapter\\Memory', $cache); }
public function setUp() { $this->cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); $this->testArray = array('foo' => 'bar', 'bar' => array('foo' => 'bar')); }
public function getServiceConfig() { return array('aliases' => array('Zend\\Cache\\Storage\\StorageInterface' => 'Zend\\Cache\\Storage\\Adapter\\Redis', 'Zend\\Cache\\Storage\\Adapter' => 'Zend\\Cache\\Storage\\Adapter\\Redis', 'Redis' => 'Zend\\Cache\\Storage\\Adapter\\Redis', 'Memcache' => 'Zend\\Cache\\Storage\\Adapter\\Memcache', 'Memcached' => 'Zend\\Cache\\Storage\\Adapter\\Memcached', 'Apc' => 'Zend\\Cache\\Storage\\Adapter\\Apc', 'LongTermCache' => 'Zend\\Cache\\Storage\\Adapter\\Redis', 'ShortTermCache' => 'Zend\\Cache\\Storage\\Adapter\\Apc', 'IntraCache' => 'Zend\\Cache\\Storage\\Adapter\\Memory'), 'invokable' => array('DpZFExtensions\\ServiceManager\\ServiceLocatorDecorator' => 'DpZFExtensions\\ServiceManager\\ServiceLocatorDecorator'), 'factories' => array('PlainRedisNoSerializer' => function ($sm) { if (class_exists('Redis')) { $redis = new Redis(); $redis->connect('localhost', 6379); $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE); return $redis; } else { return null; } }, 'Zend\\Cache\\Storage\\Adapter\\Redis' => function ($sm) { if (class_exists('Redis') && !is_null(StorageFactory::adapterFactory('redis'))) { return StorageFactory::adapterFactory('redis', array('resourceId' => 'default', 'server' => array('127.0.0.1'), 'libOptions' => array(\Redis::OPT_SERIALIZER, \Redis::SERIALIZER_IGBINARY))); } else { return StorageFactory::adapterFactory('memory'); } }, 'Zend\\Cache\\Storage\\Adapter\\Memcached' => function () { if (!is_null(StorageFactory::adapterFactory('memcached'))) { return StorageFactory::adapterFactory('memcached', array('namespace' => 'aib', 'servers' => array('127.0.0.1', 11211))); } else { return StorageFactory::adapterFactory('memory'); } }, 'Zend\\Cache\\Storage\\Adapter\\Memcache' => function () { if (!is_null(StorageFactory::adapterFactory('memcache'))) { return StorageFactory::adapterFactory('memcache'); } else { return StorageFactory::adapterFactory('memory'); } }, 'Zend\\Cache\\Storage\\Adapter\\Memory' => function () { return StorageFactory::adapterFactory('memory'); }, 'Zend\\Cache\\Storage\\Adapter\\Apc' => function () { if (extension_loaded('apc') && !is_null(StorageFactory::adapterFactory('apc'))) { return StorageFactory::adapterFactory('apc'); } else { return StorageFactory::adapterFactory('memory'); } }), 'initializers' => array(function ($instance, $serviceManager) { if ($instance instanceof ServiceLocatorAwareInterface) { $instance->setServiceLocator($serviceManager); } }, function ($instance, ServiceLocatorInterface $serviceManager) { if ($instance instanceof ICacheAware) { if ($serviceManager->has('LongTermCache')) { $instance->setLongTermCache($serviceManager->get('LongTermCache')); } elseif ($serviceManager->has('Cache')) { $instance->setLongTermCache($serviceManager->get('Cache')); } elseif ($serviceManager->has('Redis')) { $instance->setLongTermCache($serviceManager->get('Redis')); } elseif ($serviceManager->has('Memcached')) { $instance->setLongTermCache($serviceManager->get('Memcached')); } elseif ($serviceManager->has('Memcache')) { $instance->setLongTermCache($serviceManager->get('Memcache')); } elseif ($serviceManager->has('IntraCache')) { $instance->setLongTermCache($serviceManager->get('IntraCache')); } if ($serviceManager->has('ShortTermCache')) { $instance->setShortTermCache($serviceManager->get('ShortTermCache')); } elseif ($serviceManager->has('Cache')) { $instance->setShortTermCache($serviceManager->get('Cache')); } elseif ($serviceManager->has('Memcached')) { $instance->setShortTermCache($serviceManager->get('Memcached')); } elseif ($serviceManager->has('Memcache')) { $instance->setShortTermCache($serviceManager->get('Memcache')); } elseif ($serviceManager->has('Redis')) { $instance->setShortTermCache($serviceManager->get('Redis')); } elseif ($serviceManager->has('IntraCache')) { $instance->setShortTermCache($serviceManager->get('IntraCache')); } } })); }
<?php /** * Created by PhpStorm. * User: developer * Date: 11/26/15 * Time: 1:11 PM */ require 'bootstrap.php'; use Zend\Cache\StorageFactory; $cache = StorageFactory::factory(array('adapter' => array('name' => 'memcached', 'options' => array('servers' => array(array('localhost', 11211)))))); $cache = StorageFactory::adapterFactory('memcached', array('servers' => array(array('localhost', 11211)))); $test = $cache->getItem('test'); print_r("First read: {$test}\n\n"); $cache->setItem('test', 'test value in memcached'); // $test = $cache->getItem('test'); print_r("Second read: {$test}\n\n"); print_r("end\n\n");
public function __construct() { // instantiate the storage adapter $this->storage = StorageFactory::adapterFactory('memory'); parent::__construct(); }
public function setUp() { $this->cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); Locale::setCache($this->cache); }
public function testWarcraft() { $pool = StorageFactory::adapterFactory('memory ', array('ttl' => 100)); $factory = new ClientFactory('apikey', $pool); $this->assertInstanceOf('Bnet\\Warcraft\\Client', $factory->warcraft(new Region(Region::EUROPE))); }
/** * Setup APC cache * @return Zend\Cache\Manager */ public function _initCache() { $container = $this; $this['cacheManager'] = $this->share(function () use($container) { $cacheConfigs = $container['configs']['cache']; switch ($cacheConfigs['storage']) { case 'apc': $cache = StorageFactory::adapterFactory('apc', ['ttl' => $cacheConfigs['ttl']]); break; case 'memcached': $cache = StorageFactory::adapterFactory('memcached', ['ttl' => $cacheConfigs['ttl']]); break; default: $cache = StorageFactory::adapterFactory('filesystem', ['ttl' => $cacheConfigs['ttl'], 'cache_dir' => CACHE_DIR . '/sessions']); break; } $plugin = StorageFactory::pluginFactory('exception_handler', ['throw_exceptions' => true]); $cache->addPlugin($plugin); return $cache; }); }
/** * Create a storage object from a given specification * * @param array|string|Storage $storage * @throws Exception\InvalidArgumentException * @return Storage */ protected function storageFactory($storage) { if (is_array($storage)) { $storage = StorageFactory::factory($storage); } elseif (is_string($storage)) { $storage = StorageFactory::adapterFactory($storage); } elseif (!$storage instanceof Storage) { throw new Exception\InvalidArgumentException('The storage must be an instanceof Zend\\Cache\\Storage\\StorageInterface ' . 'or an array passed to Zend\\Cache\\Storage::factory ' . 'or simply the name of the storage adapter'); } return $storage; }
/** * ZF-9877 */ public function testSetCacheThroughOptions() { $cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); $translate = new Translator\Translator(array( 'adapter' => Translator\Translator::AN_ARRAY, 'content' => array('msg1' => 'Message 1 (en)'), 'locale' => 'en', 'cache' => $cache, )); $return = Translator\Translator::getCache(); $this->assertTrue($return instanceof CacheAdapter); $this->assertTrue(Translator\Translator::hasCache()); }
public function testSetOptions() { $options = Date::setOptions(); $this->assertTrue(is_array($options)); $this->assertEquals('iso', $options['format_type']); Date::setOptions(array('format_type' => 'php')); $options = Date::setOptions(); $this->assertEquals('php', $options['format_type']); try { Date::setOptions(array('format_type' => 'non')); $this->fail(); } catch (\Zend\Date\Exception $e) { // success } try { Date::setOptions(array('unknown' => 'non')); $this->fail(); } catch (\Zend\Date\Exception $e) { // success } try { Date::setOptions(array('fix_dst' => 2)); $this->fail(); } catch (\Zend\Date\Exception $e) { // success } try { Date::setOptions(array('fix_dst' => 2)); $this->fail(); } catch (\Zend\Date\Exception $e) { // success } $cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); Date\Date::setOptions(array('cache' => $cache)); }
public function setUp() { $cache = CacheFactory::adapterFactory('memory', array('memory_limit' => 0)); Cldr::setCache($cache); }