コード例 #1
0
ファイル: MemcacheTest.php プロジェクト: ehough/stash
 public function testConstructionOptions()
 {
     $key = array('apple', 'sauce');
     $options = array();
     $options['servers'][] = array('127.0.0.1', '11211', '50');
     $options['servers'][] = array('127.0.0.1', '11211');
     $options['extension'] = $this->extension;
     $driver = new ehough_stash_driver_Memcache();
     $driver->setOptions($options);
     $item = new ehough_stash_Item();
     $poolStub = new ehough_stash_test_stub_PoolGetDriverStub();
     $poolStub->setDriver($driver);
     $item->setPool($poolStub);
     $item->setKey($key);
     $this->assertTrue($item->set($key), 'Able to load and store memcache driver using multiple servers');
     $options = array();
     $options['extension'] = $this->extension;
     $driver = new ehough_stash_driver_Memcache();
     $driver->setOptions($options);
     $item = new ehough_stash_Item();
     $poolStub = new ehough_stash_test_stub_PoolGetDriverStub();
     $poolStub->setDriver($driver);
     $item->setPool($poolStub);
     $item->setKey($key);
     $this->assertTrue($item->set($key), 'Able to load and store memcache driver using default server');
 }
コード例 #2
0
ファイル: CacheExceptionTest.php プロジェクト: ehough/stash
 public function testClear()
 {
     $item = new ehough_stash_Item();
     $poolStub = new ehough_stash_test_stub_PoolGetDriverStub();
     $poolStub->setDriver(new ehough_stash_test_stub_DriverExceptionStub());
     $item->setPool($poolStub);
     $item->setKey(array('path', 'to', 'clear'));
     $this->assertFalse($item->isDisabled());
     $this->assertFalse($item->clear());
     $this->assertTrue($item->isDisabled(), 'Is disabled after exception is thrown in driver');
 }
コード例 #3
0
ファイル: SqliteAnyTest.php プロジェクト: ehough/stash
 public function testConstruction()
 {
     $key = array('apple', 'sauce');
     $options = array();
     $driver = new ehough_stash_driver_Sqlite();
     $driver->setOptions($options);
     $item = new ehough_stash_Item();
     $poolSub = new ehough_stash_test_stub_PoolGetDriverStub();
     $poolSub->setDriver($driver);
     $item->setPool($poolSub);
     $item->setKey($key);
     $this->assertTrue($item->set($key), 'Able to load and store with unconfigured extension.');
 }
コード例 #4
0
ファイル: ItemLoggerTest.php プロジェクト: ehough/stash
 protected function getItem($key, $exceptionDriver = false)
 {
     if ($exceptionDriver) {
         $fullDriver = 'ehough_stash_test_stub_DriverExceptionStub';
     } else {
         $fullDriver = 'ehough_stash_driver_Ephemeral';
     }
     $item = new ehough_stash_Item();
     $poolStub = new ehough_stash_test_stub_PoolGetDriverStub();
     $poolStub->setDriver(new $fullDriver());
     $item->setPool($poolStub);
     $item->setKey($key);
     return $item;
 }
コード例 #5
0
ファイル: EphemeralTest.php プロジェクト: ehough/stash
 public function testKeyCollisions2()
 {
     $driver = new $this->driverClass();
     $poolStub = new ehough_stash_test_stub_PoolGetDriverStub();
     $poolStub->setDriver($driver);
     $item1 = new ehough_stash_Item();
     $item1->setPool($poolStub);
     $item1->setKey(array('#'));
     $item1->set('X');
     $item2 = new ehough_stash_Item();
     $item2->setPool($poolStub);
     $item2->setKey(array(':'));
     $item2->set('Y');
     $this->assertEquals('X', $item1->get());
 }
コード例 #6
0
ファイル: FileSystemTest.php プロジェクト: ehough/stash
 /**
  * Test that the paths are created using the key hash function.
  */
 public function testOptionKeyHashFunctionDirs()
 {
     $hashfunctions = array('ehough_stash_test_driver_FileSystemTest_strdup', 'strrev', 'md5', array($this, '__callback_testOptionKeyHashFunctionDirs'));
     $paths = array('one', 'two', 'three', 'four');
     foreach ($hashfunctions as $hashfunction) {
         $driver = new ehough_stash_driver_FileSystem();
         $driver->setOptions($this->getOptions(array('keyHashFunction' => $hashfunction, 'path' => sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'stash', 'dirSplit' => 1)));
         $rand = str_repeat(uniqid(), 32);
         $item = new ehough_stash_Item();
         $poolStub = new ehough_stash_test_stub_PoolGetDriverStub();
         $poolStub->setDriver($driver);
         $item->setPool($poolStub);
         $item->setKey($paths);
         $item->set($rand);
         $allpaths = array_merge(array('cache'), $paths);
         $predicted = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'stash' . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array_map($hashfunction, $allpaths)) . $this->extension;
         $this->assertFileExists($predicted);
     }
 }
コード例 #7
0
ファイル: AbstractItemTest.php プロジェクト: ehough/stash
 public function testDisableCacheGlobally()
 {
     ehough_stash_Item::$runtimeDisable = true;
     $testDriver = $this->getMockedDriver();
     $item = $this->getItem();
     $poolStub = new ehough_stash_test_stub_PoolGetDriverStub();
     $poolStub->setDriver($this->getMockedDriver());
     $item->setPool($poolStub);
     $item->setKey(array('test', 'key'));
     $this->assertDisabledStash($item);
     $this->assertTrue($item->isDisabled());
     $this->assertFalse($testDriver->wasCalled(), 'Driver was not called after Item was disabled.');
     ehough_stash_Item::$runtimeDisable = false;
 }