diff options
author | Robin Appelman <icewind@owncloud.com> | 2015-05-19 17:30:32 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2015-05-19 17:30:32 +0200 |
commit | 2213d6597c5d052acc27e294227a10d23ba00448 (patch) | |
tree | b8e90f73c44bc66a2ef95f50958c85a5c76bf709 | |
parent | 733784ae41b67558c86da43f2a0ddbacdcf49e33 (diff) | |
download | nextcloud-server-2213d6597c5d052acc27e294227a10d23ba00448.tar.gz nextcloud-server-2213d6597c5d052acc27e294227a10d23ba00448.zip |
add tests for copyFromStorage with same storage
-rw-r--r-- | tests/lib/files/storage/storage.php | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php index 938fecb5bf3..e8602b6b24a 100644 --- a/tests/lib/files/storage/storage.php +++ b/tests/lib/files/storage/storage.php @@ -176,7 +176,7 @@ abstract class Storage extends \Test\TestCase { ]; } - public function initSourceAndTarget ($source, $target = null) { + public function initSourceAndTarget($source, $target = null) { $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $this->instance->file_put_contents($source, file_get_contents($textFile)); if ($target) { @@ -185,12 +185,12 @@ abstract class Storage extends \Test\TestCase { } } - public function assertSameAsLorem ($file) { + public function assertSameAsLorem($file) { $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $this->assertEquals( file_get_contents($textFile), $this->instance->file_get_contents($file), - 'Expected '.$file.' to be a copy of '.$textFile + 'Expected ' . $file . ' to be a copy of ' . $textFile ); } @@ -202,9 +202,9 @@ abstract class Storage extends \Test\TestCase { $this->instance->copy($source, $target); - $this->assertTrue($this->instance->file_exists($target), $target.' was not created'); + $this->assertTrue($this->instance->file_exists($target), $target . ' was not created'); $this->assertSameAsLorem($target); - $this->assertTrue($this->instance->file_exists($source), $source.' was deleted'); + $this->assertTrue($this->instance->file_exists($source), $source . ' was deleted'); } /** @@ -216,8 +216,8 @@ abstract class Storage extends \Test\TestCase { $this->instance->rename($source, $target); $this->wait(); - $this->assertTrue($this->instance->file_exists($target), $target.' was not created'); - $this->assertFalse($this->instance->file_exists($source), $source.' still exists'); + $this->assertTrue($this->instance->file_exists($target), $target . ' was not created'); + $this->assertFalse($this->instance->file_exists($source), $source . ' still exists'); $this->assertSameAsLorem($target); } @@ -225,12 +225,12 @@ abstract class Storage extends \Test\TestCase { * @dataProvider copyAndMoveProvider */ public function testCopyOverwrite($source, $target) { - $this->initSourceAndTarget($source,$target); + $this->initSourceAndTarget($source, $target); $this->instance->copy($source, $target); - $this->assertTrue($this->instance->file_exists($target), $target.' was not created'); - $this->assertTrue($this->instance->file_exists($source), $source.' was deleted'); + $this->assertTrue($this->instance->file_exists($target), $target . ' was not created'); + $this->assertTrue($this->instance->file_exists($source), $source . ' was deleted'); $this->assertSameAsLorem($target); $this->assertSameAsLorem($source); } @@ -243,8 +243,8 @@ abstract class Storage extends \Test\TestCase { $this->instance->rename($source, $target); - $this->assertTrue($this->instance->file_exists($target), $target.' was not created'); - $this->assertFalse($this->instance->file_exists($source), $source.' still exists'); + $this->assertTrue($this->instance->file_exists($target), $target . ' was not created'); + $this->assertFalse($this->instance->file_exists($source), $source . ' still exists'); $this->assertSameAsLorem($target); } @@ -535,4 +535,17 @@ abstract class Storage extends \Test\TestCase { $this->assertTrue($this->instance->instanceOfStorage(get_class($this->instance))); $this->assertFalse($this->instance->instanceOfStorage('\OC')); } + + /** + * @dataProvider copyAndMoveProvider + */ + public function testCopyFromSameStorage($source, $target) { + $this->initSourceAndTarget($source); + + $this->instance->copyFromStorage($this->instance, $source, $target); + + $this->assertTrue($this->instance->file_exists($target), $target . ' was not created'); + $this->assertSameAsLorem($target); + $this->assertTrue($this->instance->file_exists($source), $source . ' was deleted'); + } } |