本文整理汇总了PHP中OC\Files\Storage\Storage::rename方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::rename方法的具体用法?PHP Storage::rename怎么用?PHP Storage::rename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Storage\Storage
的用法示例。
在下文中一共展示了Storage::rename方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateStorageMTime
public function testUpdateStorageMTime()
{
$this->storage->mkdir('sub');
$this->storage->mkdir('sub2');
$this->storage->file_put_contents('sub/foo.txt', 'qwerty');
$this->updater->update('sub');
$this->updater->update('sub/foo.txt');
$this->updater->update('sub2');
$cachedSourceParent = $this->cache->get('sub');
$cachedSource = $this->cache->get('sub/foo.txt');
$this->storage->rename('sub/foo.txt', 'sub2/bar.txt');
// simulate storage having a different mtime
$testmtime = 1433323578;
// source storage mtime change
$this->storage->touch('sub', $testmtime);
// target storage mtime change
$this->storage->touch('sub2', $testmtime);
// some storages (like Dropbox) change storage mtime on rename
$this->storage->touch('sub2/bar.txt', $testmtime);
$this->updater->renameFromStorage($this->storage, 'sub/foo.txt', 'sub2/bar.txt');
$cachedTargetParent = $this->cache->get('sub2');
$cachedTarget = $this->cache->get('sub2/bar.txt');
$this->assertEquals($cachedSource['mtime'], $cachedTarget['mtime'], 'file mtime preserved');
$this->assertNotEquals($cachedTarget['storage_mtime'], $cachedTarget['mtime'], 'mtime is not storage_mtime for moved file');
$this->assertEquals($testmtime, $cachedTarget['storage_mtime'], 'target file storage_mtime propagated');
$this->assertNotEquals($testmtime, $cachedTarget['mtime'], 'target file mtime changed, not from storage');
$this->assertEquals($testmtime, $cachedTargetParent['storage_mtime'], 'target parent storage_mtime propagated');
$this->assertNotEquals($testmtime, $cachedTargetParent['mtime'], 'target folder mtime changed, not from storage');
}
示例2: testMoveDisabled
public function testMoveDisabled()
{
$this->storage->file_put_contents('foo.txt', 'qwerty');
$this->updater->update('foo.txt');
$this->assertTrue($this->cache->inCache('foo.txt'));
$this->assertFalse($this->cache->inCache('bar.txt'));
$cached = $this->cache->get('foo.txt');
$this->storage->rename('foo.txt', 'bar.txt');
$this->assertTrue($this->cache->inCache('foo.txt'));
$this->assertFalse($this->cache->inCache('bar.txt'));
$this->updater->disable();
$this->updater->rename('foo.txt', 'bar.txt');
$this->assertTrue($this->cache->inCache('foo.txt'));
$this->assertFalse($this->cache->inCache('bar.txt'));
}
示例3: testMove
public function testMove()
{
$this->storage->file_put_contents('foo.txt', 'qwerty');
$this->updater->update('foo.txt');
$this->assertTrue($this->cache->inCache('foo.txt'));
$this->assertFalse($this->cache->inCache('bar.txt'));
$cached = $this->cache->get('foo.txt');
$this->storage->rename('foo.txt', 'bar.txt');
$this->assertTrue($this->cache->inCache('foo.txt'));
$this->assertFalse($this->cache->inCache('bar.txt'));
$this->updater->rename('foo.txt', 'bar.txt');
$this->assertFalse($this->cache->inCache('foo.txt'));
$this->assertTrue($this->cache->inCache('bar.txt'));
$cachedTarget = $this->cache->get('bar.txt');
$this->assertEquals($cached['etag'], $cachedTarget['etag']);
$this->assertEquals($cached['mtime'], $cachedTarget['mtime']);
$this->assertEquals($cached['size'], $cachedTarget['size']);
$this->assertEquals($cached['fileid'], $cachedTarget['fileid']);
}
示例4: rename
/**
* see http://php.net/manual/en/function.rename.php
*
* @param string $path1
* @param string $path2
* @return bool
*/
public function rename($path1, $path2)
{
return $this->storage->rename($path1, $path2);
}