diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-07-01 17:57:40 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-05-28 18:16:23 +0200 |
commit | 03ba497a8c1e149857d6c3a4d4cab49dea5903c1 (patch) | |
tree | acc2cac257a525bb388d81842ba675358b00efc7 /tests | |
parent | 38c1da09768d034ee788f0c6a4284591e914fe4a (diff) | |
download | nextcloud-server-03ba497a8c1e149857d6c3a4d4cab49dea5903c1.tar.gz nextcloud-server-03ba497a8c1e149857d6c3a4d4cab49dea5903c1.zip |
add recursive copy to local storage backend
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/storage/storage.php | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php index 4a4626fc5c5..24390f05367 100644 --- a/tests/lib/files/storage/storage.php +++ b/tests/lib/files/storage/storage.php @@ -373,7 +373,7 @@ abstract class Storage extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->instance->file_exists('source/test1.txt')); $this->assertFalse($this->instance->file_exists('source/test2.txt')); $this->assertFalse($this->instance->file_exists('source/subfolder')); - $this->assertFalse($this->instance->file_exists('source/test.txt')); + $this->assertFalse($this->instance->file_exists('source/subfolder/test.txt')); $this->assertTrue($this->instance->file_exists('target')); $this->assertTrue($this->instance->file_exists('target/test1.txt')); @@ -401,4 +401,67 @@ abstract class Storage extends \PHPUnit_Framework_TestCase { $this->assertFalse($this->instance->file_exists('target/test2.txt')); $this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt')); } + + public function testRenameOverWriteDirectoryOverFile() { + $this->instance->mkdir('source'); + $this->instance->file_put_contents('source/test1.txt', 'foo'); + + $this->instance->file_put_contents('target', 'bar'); + + $this->instance->rename('source', 'target'); + + $this->assertFalse($this->instance->file_exists('source')); + $this->assertFalse($this->instance->file_exists('source/test1.txt')); + $this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt')); + } + + public function testCopyDirectory() { + $this->instance->mkdir('source'); + $this->instance->file_put_contents('source/test1.txt', 'foo'); + $this->instance->file_put_contents('source/test2.txt', 'qwerty'); + $this->instance->mkdir('source/subfolder'); + $this->instance->file_put_contents('source/subfolder/test.txt', 'bar'); + $this->instance->copy('source', 'target'); + + $this->assertTrue($this->instance->file_exists('source')); + $this->assertTrue($this->instance->file_exists('source/test1.txt')); + $this->assertTrue($this->instance->file_exists('source/test2.txt')); + $this->assertTrue($this->instance->file_exists('source/subfolder')); + $this->assertTrue($this->instance->file_exists('source/subfolder/test.txt')); + + $this->assertTrue($this->instance->file_exists('target')); + $this->assertTrue($this->instance->file_exists('target/test1.txt')); + $this->assertTrue($this->instance->file_exists('target/test2.txt')); + $this->assertTrue($this->instance->file_exists('target/subfolder')); + $this->assertTrue($this->instance->file_exists('target/subfolder/test.txt')); + + $this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt')); + $this->assertEquals('qwerty', $this->instance->file_get_contents('target/test2.txt')); + $this->assertEquals('bar', $this->instance->file_get_contents('target/subfolder/test.txt')); + } + + public function testCopyOverWriteDirectory() { + $this->instance->mkdir('source'); + $this->instance->file_put_contents('source/test1.txt', 'foo'); + + $this->instance->mkdir('target'); + $this->instance->file_put_contents('target/test1.txt', 'bar'); + $this->instance->file_put_contents('target/test2.txt', 'bar'); + + $this->instance->copy('source', 'target'); + + $this->assertFalse($this->instance->file_exists('target/test2.txt')); + $this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt')); + } + + public function testCopyOverWriteDirectoryOverFile() { + $this->instance->mkdir('source'); + $this->instance->file_put_contents('source/test1.txt', 'foo'); + + $this->instance->file_put_contents('target', 'bar'); + + $this->instance->copy('source', 'target'); + + $this->assertEquals('foo', $this->instance->file_get_contents('target/test1.txt')); + } } |