summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-06-23 16:29:01 +0200
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-06-23 16:29:01 +0200
commit28c1a9557561319910bb86e9d04afcf6bb4bbf4f (patch)
tree3a39fbacbef3529c51aa63acb079abf79fb716b8 /tests
parent7ec53571c4b0df361aedc82204d5dba0cca1fd0b (diff)
downloadnextcloud-server-28c1a9557561319910bb86e9d04afcf6bb4bbf4f.tar.gz
nextcloud-server-28c1a9557561319910bb86e9d04afcf6bb4bbf4f.zip
use common storage test
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/objectstore/swift.php204
1 files changed, 7 insertions, 197 deletions
diff --git a/tests/lib/files/objectstore/swift.php b/tests/lib/files/objectstore/swift.php
index d05af4d6587..8ac899288e6 100644
--- a/tests/lib/files/objectstore/swift.php
+++ b/tests/lib/files/objectstore/swift.php
@@ -25,17 +25,13 @@ use OC\Files\ObjectStore\Swift as ObjectStoreToTest;
use PHPUnit_Framework_TestCase;
-class Swift extends PHPUnit_Framework_TestCase {
-
- /**
- * @var \OC\Files\ObjectStore\Swift $storage
- */
- private $storage;
+//class Swift extends PHPUnit_Framework_TestCase {
+class Swift extends \Test\Files\Storage\Storage {
private $objectStorage;
-
+
public function setUp() {
-
+
\OC_App::disable('files_sharing');
\OC_App::disable('files_versions');
@@ -72,202 +68,16 @@ class Swift extends PHPUnit_Framework_TestCase {
);
$this->objectStorage = new ObjectStoreToTest($params);
$params['objectstore'] = $this->objectStorage;
- $this->storage = new ObjectStoreStorage($params);
+ $this->instance = new ObjectStoreStorage($params);
}
public function tearDown() {
- if (is_null($this->storage)) {
+ if (is_null($this->instance)) {
return;
}
$this->objectStorage->deleteContainer(true);
- $this->storage->getCache()->clear();
+ $this->instance->getCache()->clear();
//TODO how do I clear hooks?
}
-
- public function testStat () {
- $stat = $this->storage->stat('');
- $this->assertInternalType('array', $stat);
- $this->assertEquals(-1, $stat['parent']);
- $this->assertEquals('', $stat['path']);
- $this->assertEquals('', $stat['name']);
- $this->assertEquals(0, $stat['size']);
- }
- public function testMkdir () {
- $root = $this->storage->stat('');
-
- $statBefore = $this->storage->stat('someuser');
- $this->assertFalse($statBefore);
-
- $this->storage->mkdir('someuser');
- $statAfter = $this->storage->stat('someuser');
-
- $this->assertTrue(is_array($statAfter));
- $this->assertEquals($root['fileid'], $statAfter['parent']);
- $this->assertEquals('someuser', $statAfter['path']);
- $this->assertEquals('someuser', $statAfter['name']);
- $this->assertEquals(0, $statAfter['size']);
-
- }
-
- public function filesProvider() {
- return array(
- array('file.txt'),
- array(' file.txt'),
- array('file.txt '),
- array('file with space.txt'),
- array('spéciäl fìle.txt'),
- array('☠ skull and crossbones.txt'),
- array('skull and crossbones ☠ in between.txt'),
- array('💩 pile of poo.txt'),
- array('pile of 💩.txt'),
- // check if someone tries to guess type on a date string
- array('2013-04-25'),
- );
- }
- /**
- * @dataProvider filesProvider
- */
- public function testTouch ($file) {
- $root = $this->storage->stat('');
-
- $statBefore = $this->storage->stat($file);
- $this->assertFalse($statBefore);
-
- $this->assertTrue($this->storage->touch($file));
- $statAfter = $this->storage->stat($file);
-
- $this->assertTrue(is_array($statAfter));
- $this->assertEquals($root['fileid'], $statAfter['parent']);
- $this->assertEquals($file, $statAfter['path']);
- $this->assertEquals($file, $statAfter['name']);
- $this->assertEquals(0, $statAfter['size']);
-
- $this->assertFalse($this->storage->touch('non-existing/'.$file));
-
- //TODO test mtime
- //TODO test existing files
- //TODO test folders
- }
- /**
- * @dataProvider filesProvider
- */
- public function testUnlink ($file) {
- $root = $this->storage->stat('');
-
- $this->assertFalse($this->storage->unlink($file));
-
- $this->storage->touch($file);
- $statBefore = $this->storage->stat($file);
-
- $this->assertTrue(is_array($statBefore));
- $this->assertEquals($root['fileid'], $statBefore['parent']);
- $this->assertEquals($file, $statBefore['path']);
- $this->assertEquals($file, $statBefore['name']);
- $this->assertEquals(0, $statBefore['size']);
-
- $this->assertTrue($this->storage->unlink($file));
-
- $this->assertFalse($this->storage->stat($file));
-
- //TODO test folders
- }
-
- /**
- * checks several methods by creating directories:
- * - file_exists (f/t)
- * - mkdir (t/f)
- * - is_dir (t)
- * - is_file (f)
- * - filetype ('dir')
- * - filesize (0)
- * - isReadable (t)
- * - isUpdateable (t)
- * - opendir (dir array/empty array)
- * - rmdir (t/f)
- * @dataProvider directoryProvider
- */
- public function testDirectories($directory) {
- $this->assertFalse($this->storage->file_exists('/' . $directory), 'Expected /'.$directory.' to not exist');
-
- $this->assertTrue($this->storage->mkdir('/' . $directory), 'Expected creating /'.$directory.' to succeed');
-
- $this->assertTrue($this->storage->file_exists('/' . $directory), 'Expected /'.$directory.' to exist');
- $this->assertTrue($this->storage->is_dir('/' . $directory), 'Expected /'.$directory.' to be a directory');
- $this->assertFalse($this->storage->is_file('/' . $directory), 'Expected /'.$directory.' not to be a file');
- $this->assertEquals('dir', $this->storage->filetype('/' . $directory), 'Expected /'.$directory.' to have filetype \'dir\'');
- $this->assertEquals(0, $this->storage->filesize('/' . $directory), 'Expected /'.$directory.' to have size 0');
- $this->assertTrue($this->storage->isReadable('/' . $directory), 'Expected /'.$directory.' to be readable');
- $this->assertTrue($this->storage->isUpdatable('/' . $directory), 'Expected /'.$directory.' to be updateable');
-
- $dh = $this->storage->opendir('');
- $content = array();
- while ($file = readdir($dh)) {
- if ($file != '.' and $file != '..') {
- $content[] = $file;
- }
- }
- $this->assertEquals(array($directory), $content);
-
- $this->assertFalse($this->storage->mkdir('/' . $directory), 'Expected already existing folder /'.$directory.' to not be createable');
- $this->assertTrue($this->storage->rmdir('/' . $directory));
-
- $this->assertFalse($this->storage->file_exists('/' . $directory));
-
- $this->assertFalse($this->storage->rmdir('/' . $directory), 'Expected not existing folder /'.$directory.' to not be removable');
-
- $dh = $this->storage->opendir('/');
- $content = array();
- while ($file = readdir($dh)) {
- if ($file != '.' and $file != '..') {
- $content[] = $file;
- }
- }
- $this->assertEquals(array(), $content);
- }
-
- public function directoryProvider() {
- return array(
- array('folder'),
- array(' folder'),
- array('folder '),
- array('folder with space'),
- array('spéciäl földer'),
- array('☠ skull and crossbones'),
- array('skull and crossbones ☠ in between'),
- array('💩 pile of poo'),
- array('pile of 💩'),
- // check if someone tries to guess type on a date string
- array('2013-04-25'),
- );
- }
-
- public function testCopyAndMove() {
- $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
- $this->storage->file_put_contents('/source.txt', file_get_contents($textFile));
- $this->storage->copy('/source.txt', '/target.txt');
- $this->assertTrue($this->storage->file_exists('/target.txt'));
- $this->assertEquals($this->storage->file_get_contents('/source.txt'), $this->storage->file_get_contents('/target.txt'));
-
- $this->storage->rename('/source.txt', '/target2.txt');
- $this->assertTrue($this->storage->file_exists('/target2.txt'));
- $this->assertFalse($this->storage->file_exists('/source.txt'));
- $this->assertEquals(file_get_contents($textFile), $this->storage->file_get_contents('/target2.txt'));
-
- // move to overwrite
- $testContents = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $this->storage->file_put_contents('/target3.txt', $testContents);
- $this->storage->rename('/target2.txt', '/target3.txt');
- $this->assertTrue($this->storage->file_exists('/target3.txt'));
- $this->assertFalse($this->storage->file_exists('/target2.txt'));
- $this->assertEquals(file_get_contents($textFile), $this->storage->file_get_contents('/target3.txt'));
- }
-
- //fopen
- //filetype test
- //getMimetype
- //getURN?!?!
- //test?
- //getConnection
- //writeback
}