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'))); }
public function testStorageProperties() { $storage = new ezcCacheStorageMemcachePlain('.', array('host' => 'localhost', 'port' => 11211, 'ttl' => 10)); $storage->reset(); $this->assertTrue(isset($storage->options)); $this->assertInstanceOf('ezcCacheStorageMemcacheOptions', $storage->options); $this->assertSetProperty($storage, 'options', array(new ezcCacheStorageMemcacheOptions())); $this->assertSetPropertyFails($storage, 'options', array('foo', 23, 42.23, true, false, new stdClass())); $this->assertFalse(isset($storage->foo)); try { $storage->foo = 23; $this->fail('Exception not thrown on set for invalid property.'); } catch (ezcBasePropertyNotFoundException $e) { } try { echo $storage->foo; $this->fail('Exception not thrown on get for invalid property.'); } catch (ezcBasePropertyNotFoundException $e) { } }