diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-07-01 17:40:19 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2014-05-28 18:16:23 +0200 |
commit | c99e254178c52a568e4070fadab894d321efa6bf (patch) | |
tree | 945a0e2bddea8b2798c25e569f3ecde37ee57034 /tests/lib | |
parent | 6d57e4c491aa8e09ff20f7ef9e2fb5618f75de48 (diff) | |
download | nextcloud-server-c99e254178c52a568e4070fadab894d321efa6bf.tar.gz nextcloud-server-c99e254178c52a568e4070fadab894d321efa6bf.zip |
aditional test cases for copy and rename
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/files/storage/storage.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php index 38cd17ac8c9..92afd47673a 100644 --- a/tests/lib/files/storage/storage.php +++ b/tests/lib/files/storage/storage.php @@ -345,4 +345,44 @@ abstract class Storage extends \PHPUnit_Framework_TestCase { $this->assertEquals(array('test.txt'), $content); } + + public function testCopyOverWriteFile() { + $this->instance->file_put_contents('target.txt', 'foo'); + $this->instance->file_put_contents('source.txt', 'bar'); + $this->instance->copy('source.txt', 'target.txt'); + $this->assertEquals('bar', $this->instance->file_get_contents('target.txt')); + } + + public function testRenameOverWriteFile() { + $this->instance->file_put_contents('target.txt', 'foo'); + $this->instance->file_put_contents('source.txt', 'bar'); + $this->instance->rename('source.txt', 'target.txt'); + $this->assertEquals('bar', $this->instance->file_get_contents('target.txt')); + $this->assertFalse($this->instance->file_exists('source.txt')); + } + + public function testRenameDirectory() { + $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->rename('source', 'target'); + + $this->assertFalse($this->instance->file_exists('source')); + $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->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')); + } } |