예제 #1
0
 protected function setup()
 {
     if (!self::$stackInitialized) {
         if (ezcBaseFeatures::hasExtensionSupport('apc')) {
             $memoryStorage = new ezcCacheStorageApcPlain();
         } else {
             if (ezcBaseFeatures::hasExtensionSupport('memcache')) {
                 $memoryStorage = new ezcCacheStorageMemcachePlain('foo');
             } else {
                 $this->markTestSkipped('APC or Memcached needed to run this test.');
             }
         }
         // Start cleanly
         $memoryStorage->reset();
         $tmpDir = $this->createTempDir(__CLASS__);
         $tmpDirEvalArray = "{$tmpDir}/plain";
         $tmpDirArray = "{$tmpDir}/array";
         mkdir($tmpDirEvalArray);
         mkdir($tmpDirArray);
         $fileStorageEvalArray = new ezcCacheStorageFileEvalArray($tmpDirEvalArray);
         $fileStorageArray = new ezcCacheStorageFileArray($tmpDirArray);
         ezcCacheStackTestConfigurator::reset();
         ezcCacheStackTestConfigurator::$storages = array(new ezcCacheStackStorageConfiguration('eval_array_storage', $fileStorageEvalArray, 10, 0.8), new ezcCacheStackStorageConfiguration('array_storage', $fileStorageArray, 8, 0.5), new ezcCacheStackStorageConfiguration('memory_storage', $memoryStorage, 5, 0.5));
         ezcCacheStackTestConfigurator::$metaStorage = $fileStorageArray;
         ezcCacheManager::createCache(__CLASS__, null, 'ezcCacheStack', new ezcCacheStackOptions(array('configurator' => 'ezcCacheStackTestConfigurator', 'replacementStrategy' => 'ezcCacheStackLfuReplacementStrategy')));
         self::$stackInitialized = true;
     }
     $this->testDataArray = array(array('id_1', 'id_1_content', array('lang' => 'en', 'area' => 'news')), array('id_2', 'id_2_content', array('lang' => 'en', 'area' => 'news')), array('id_3', 'id_3_content', array('lang' => 'de', 'area' => 'news')), array('id_4', 'id_4_content', array('lang' => 'no', 'area' => 'news')), array('id_5', 'id_5_content', array('lang' => 'de', 'area' => 'news')));
 }
예제 #2
0
파일: stack_test.php 프로젝트: bmdevel/ezc
 public function testCtorWithConfigurator()
 {
     $configuredOptions = new ezcCacheStackOptions();
     ezcCacheStackTestConfigurator::$options = $configuredOptions;
     ezcCacheStackTestConfigurator::$storages = array(new ezcCacheStackStorageConfiguration('1', new ezcCacheStorageFileArray($this->createTempDir(__CLASS__)), 10, 0.4));
     $options = new ezcCacheStackOptions();
     $location = 'foo';
     $options->configurator = 'ezcCacheStackTestConfigurator';
     $stack = new ezcCacheStack($location, $options);
     $this->assertSame($configuredOptions, $stack->options);
     $this->assertAttributeEquals(ezcCacheStackTestConfigurator::$storages, 'storageStack', $stack);
     $this->removeTempDir();
 }
 public static function reset()
 {
     self::$storages = array();
     self::$metaStorage = null;
     self::$options = null;
 }