summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-06-27 17:51:37 +0200
committerBart Visscher <bartv@thisnet.nl>2013-06-27 17:54:17 +0200
commitc6bbccc776ee9ea1112d3cfab54c9f2c95540130 (patch)
tree799c938b8d314a4f49fdeba43f5b42e212f77fcd /tests
parent969e43c87b7afb6184846fe27849167c9c6f5eab (diff)
parent6fcee1ee117a167aa0c526ca39effbf086d10991 (diff)
downloadnextcloud-server-c6bbccc776ee9ea1112d3cfab54c9f2c95540130.tar.gz
nextcloud-server-c6bbccc776ee9ea1112d3cfab54c9f2c95540130.zip
Merge branch 'master' into convert-oc_config
Conflicts: lib/config.php lib/setup.php
Diffstat (limited to 'tests')
-rw-r--r--tests/data/db_structure.xml4
-rw-r--r--tests/data/db_structure2.xml2
-rw-r--r--tests/lib/db.php33
-rw-r--r--tests/lib/dbschema.php14
-rw-r--r--tests/lib/files/cache/cache.php4
-rw-r--r--tests/lib/files/cache/scanner.php51
-rw-r--r--tests/lib/files/cache/updater.php129
-rw-r--r--tests/lib/files/cache/watcher.php6
-rw-r--r--tests/lib/files/mapper.php18
-rw-r--r--tests/lib/files/view.php24
-rw-r--r--tests/lib/geo.php4
-rw-r--r--tests/lib/helper.php9
-rw-r--r--tests/phpunit-autotest.xml13
13 files changed, 276 insertions, 35 deletions
diff --git a/tests/data/db_structure.xml b/tests/data/db_structure.xml
index af2e5ce3439..8f6dc5e2ecd 100644
--- a/tests/data/db_structure.xml
+++ b/tests/data/db_structure.xml
@@ -9,7 +9,7 @@
<table>
- <name>*dbprefix*contacts_addressbooks</name>
+ <name>*dbprefix*cntcts_addrsbks</name>
<declaration>
@@ -77,7 +77,7 @@
<table>
- <name>*dbprefix*contacts_cards</name>
+ <name>*dbprefix*cntcts_cards</name>
<declaration>
diff --git a/tests/data/db_structure2.xml b/tests/data/db_structure2.xml
index c1bbb550483..fc6fe0bba7d 100644
--- a/tests/data/db_structure2.xml
+++ b/tests/data/db_structure2.xml
@@ -9,7 +9,7 @@
<table>
- <name>*dbprefix*contacts_addressbooks</name>
+ <name>*dbprefix*cntcts_addrsbks</name>
<declaration>
diff --git a/tests/lib/db.php b/tests/lib/db.php
index 440f3fb6bfd..afbdb413c3d 100644
--- a/tests/lib/db.php
+++ b/tests/lib/db.php
@@ -22,8 +22,8 @@ class Test_DB extends PHPUnit_Framework_TestCase {
OC_DB::createDbFromStructure(self::$schema_file);
$this->test_prefix = $r;
- $this->table1 = $this->test_prefix.'contacts_addressbooks';
- $this->table2 = $this->test_prefix.'contacts_cards';
+ $this->table1 = $this->test_prefix.'cntcts_addrsbks';
+ $this->table2 = $this->test_prefix.'cntcts_cards';
$this->table3 = $this->test_prefix.'vcategory';
}
@@ -33,38 +33,41 @@ class Test_DB extends PHPUnit_Framework_TestCase {
}
public function testQuotes() {
- $query = OC_DB::prepare('SELECT `fullname` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+ $query = OC_DB::prepare('SELECT `fullname` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(array('uri_1'));
$this->assertTrue((bool)$result);
$row = $result->fetchRow();
- $this->assertFalse($row);
- $query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`,`uri`) VALUES (?,?)');
+ $this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null
+ $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result = $query->execute(array('fullname test', 'uri_1'));
$this->assertTrue((bool)$result);
- $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+ $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(array('uri_1'));
$this->assertTrue((bool)$result);
$row = $result->fetchRow();
$this->assertArrayHasKey('fullname', $row);
$this->assertEquals($row['fullname'], 'fullname test');
$row = $result->fetchRow();
- $this->assertFalse($row);
+ $this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null
}
+ /**
+ * @medium
+ */
public function testNOW() {
- $query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`,`uri`) VALUES (NOW(),?)');
+ $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (NOW(),?)');
$result = $query->execute(array('uri_2'));
$this->assertTrue((bool)$result);
- $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+ $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(array('uri_2'));
$this->assertTrue((bool)$result);
}
public function testUNIX_TIMESTAMP() {
- $query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`,`uri`) VALUES (UNIX_TIMESTAMP(),?)');
+ $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (UNIX_TIMESTAMP(),?)');
$result = $query->execute(array('uri_3'));
$this->assertTrue((bool)$result);
- $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+ $query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(array('uri_3'));
$this->assertTrue((bool)$result);
}
@@ -88,7 +91,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$this->assertTrue((bool)$result);
}
- $query = OC_DB::prepare('SELECT * FROM *PREFIX*'.$this->table3);
+ $query = OC_DB::prepare('SELECT * FROM `*PREFIX*'.$this->table3.'`');
$result = $query->execute();
$this->assertTrue((bool)$result);
$this->assertEquals('4', $result->numRows());
@@ -100,10 +103,10 @@ class Test_DB extends PHPUnit_Framework_TestCase {
$carddata = 'This is a vCard';
// Normal test to have same known data inserted.
- $query = OC_DB::prepare('INSERT INTO *PREFIX*'.$this->table2.' (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)');
+ $query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`, `uri`, `carddata`) VALUES (?, ?, ?)');
$result = $query->execute(array($fullname, $uri, $carddata));
$this->assertTrue((bool)$result);
- $query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+ $query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(array($uri));
$this->assertTrue((bool)$result);
$row = $result->fetchRow();
@@ -119,7 +122,7 @@ class Test_DB extends PHPUnit_Framework_TestCase {
));
$this->assertTrue((bool)$result);
- $query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM *PREFIX*'.$this->table2.' WHERE `uri` = ?');
+ $query = OC_DB::prepare('SELECT `fullname`, `uri`, `carddata` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(array($uri));
$this->assertTrue((bool)$result);
$row = $result->fetchRow();
diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php
index e20a04ef7fd..59f203993ef 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/dbschema.php
@@ -26,8 +26,8 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
file_put_contents( self::$schema_file2, $content );
$this->test_prefix = $r;
- $this->table1 = $this->test_prefix.'contacts_addressbooks';
- $this->table2 = $this->test_prefix.'contacts_cards';
+ $this->table1 = $this->test_prefix.'cntcts_addrsbks';
+ $this->table2 = $this->test_prefix.'cntcts_cards';
}
public function tearDown() {
@@ -36,6 +36,9 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
}
// everything in one test, they depend on each other
+ /**
+ * @medium
+ */
public function testSchema() {
$this->doTestSchemaCreating();
$this->doTestSchemaChanging();
@@ -91,13 +94,18 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase {
break;
case 'pgsql':
$sql = "SELECT tablename AS table_name, schemaname AS schema_name "
- . "FROM pg_tables WHERE schemaname NOT LIKE 'pg_%' "
+ . "FROM pg_tables WHERE schemaname NOT LIKE 'pg_%' "
. "AND schemaname != 'information_schema' "
. "AND tablename = '".$table."'";
$query = OC_DB::prepare($sql);
$result = $query->execute(array());
$exists = $result && $result->fetchOne();
break;
+ case 'oci':
+ $sql = 'SELECT table_name FROM user_tables WHERE table_name = ?';
+ $result = \OC_DB::executeAudited($sql, array($table));
+ $exists = (bool)$result->fetchOne(); //oracle uses MDB2 and returns null
+ break;
case 'mssql':
$sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{$table}'";
$query = OC_DB::prepare($sql);
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index f272655925b..527c1d1b2a1 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -348,7 +348,9 @@ class Cache extends \PHPUnit_Framework_TestCase {
}
public function tearDown() {
- $this->cache->clear();
+ if ($this->cache) {
+ $this->cache->clear();
+ }
}
public function setUp() {
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php
index 3885c99e6d3..042bf8991f6 100644
--- a/tests/lib/files/cache/scanner.php
+++ b/tests/lib/files/cache/scanner.php
@@ -104,7 +104,7 @@ class Scanner extends \PHPUnit_Framework_TestCase {
$this->assertNotEquals($cachedDataFolder['size'], -1);
}
- function testBackgroundScan(){
+ function testBackgroundScan() {
$this->fillTestFolders();
$this->storage->mkdir('folder2');
$this->storage->file_put_contents('folder2/bar.txt', 'foobar');
@@ -126,6 +126,45 @@ class Scanner extends \PHPUnit_Framework_TestCase {
$this->assertFalse($this->cache->getIncomplete());
}
+ public function testReuseExisting() {
+ $this->fillTestFolders();
+
+ $this->scanner->scan('');
+ $oldData = $this->cache->get('');
+ $this->storage->unlink('folder/bar.txt');
+ $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE);
+ $newData = $this->cache->get('');
+ $this->assertNotEquals($oldData['etag'], $newData['etag']);
+ $this->assertEquals($oldData['size'], $newData['size']);
+
+ $oldData = $newData;
+ $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
+ $newData = $this->cache->get('');
+ $this->assertEquals($oldData['etag'], $newData['etag']);
+ $this->assertEquals(-1, $newData['size']);
+ }
+
+ public function testRemovedFile() {
+ $this->fillTestFolders();
+
+ $this->scanner->scan('');
+ $this->assertTrue($this->cache->inCache('foo.txt'));
+ $this->storage->unlink('foo.txt');
+ $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
+ $this->assertFalse($this->cache->inCache('foo.txt'));
+ }
+
+ public function testRemovedFolder() {
+ $this->fillTestFolders();
+
+ $this->scanner->scan('');
+ $this->assertTrue($this->cache->inCache('folder/bar.txt'));
+ $this->storage->unlink('/folder');
+ $this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
+ $this->assertFalse($this->cache->inCache('folder'));
+ $this->assertFalse($this->cache->inCache('folder/bar.txt'));
+ }
+
function setUp() {
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->scanner = new \OC\Files\Cache\Scanner($this->storage);
@@ -133,9 +172,11 @@ class Scanner extends \PHPUnit_Framework_TestCase {
}
function tearDown() {
- $ids = $this->cache->getAll();
- $permissionsCache = $this->storage->getPermissionsCache();
- $permissionsCache->removeMultiple($ids, \OC_User::getUser());
- $this->cache->clear();
+ if ($this->cache) {
+ $ids = $this->cache->getAll();
+ $permissionsCache = $this->storage->getPermissionsCache();
+ $permissionsCache->removeMultiple($ids, \OC_User::getUser());
+ $this->cache->clear();
+ }
}
}
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php
index dad3cd7e650..b2db27e42e0 100644
--- a/tests/lib/files/cache/updater.php
+++ b/tests/lib/files/cache/updater.php
@@ -56,7 +56,7 @@ class Updater extends \PHPUnit_Framework_TestCase {
\OC_Hook::connect('OC_Filesystem', 'post_write', '\OC\Files\Cache\Updater', 'writeHook');
\OC_Hook::connect('OC_Filesystem', 'post_delete', '\OC\Files\Cache\Updater', 'deleteHook');
\OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Updater', 'renameHook');
-
+ \OC_Hook::connect('OC_Filesystem', 'post_touch', '\OC\Files\Cache\Updater', 'touchHook');
}
public function tearDown() {
@@ -69,6 +69,7 @@ class Updater extends \PHPUnit_Framework_TestCase {
public function testWrite() {
$textSize = strlen("dummy file data\n");
$imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png');
+ $this->cache->put('foo.txt', array('mtime' => 100));
$rootCachedData = $this->cache->get('');
$this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
@@ -77,11 +78,9 @@ class Updater extends \PHPUnit_Framework_TestCase {
$cachedData = $this->cache->get('foo.txt');
$this->assertEquals(3, $cachedData['size']);
$this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
- $mtime = $cachedData['mtime'];
$cachedData = $this->cache->get('');
$this->assertEquals(2 * $textSize + $imageSize + 3, $cachedData['size']);
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
- $this->assertGreaterThanOrEqual($rootCachedData['mtime'], $mtime);
$rootCachedData = $cachedData;
$this->assertFalse($this->cache->inCache('bar.txt'));
@@ -96,6 +95,27 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $mtime);
}
+ public function testWriteWithMountPoints() {
+ $storage2 = new \OC\Files\Storage\Temporary(array());
+ $cache2 = $storage2->getCache();
+ Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
+ $folderCachedData = $this->cache->get('folder');
+ $substorageCachedData = $cache2->get('');
+ Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
+ $this->assertTrue($cache2->inCache('foo.txt'));
+ $cachedData = $cache2->get('foo.txt');
+ $this->assertEquals(3, $cachedData['size']);
+ $mtime = $cachedData['mtime'];
+
+ $cachedData = $cache2->get('');
+ $this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($mtime, $cachedData['mtime']);
+
+ $cachedData = $this->cache->get('folder');
+ $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($mtime, $cachedData['mtime']);
+ }
+
public function testDelete() {
$textSize = strlen("dummy file data\n");
$imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png');
@@ -103,7 +123,7 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
$this->assertTrue($this->cache->inCache('foo.txt'));
- Filesystem::unlink('foo.txt', 'asd');
+ Filesystem::unlink('foo.txt');
$this->assertFalse($this->cache->inCache('foo.txt'));
$cachedData = $this->cache->get('');
$this->assertEquals(2 * $textSize + $imageSize, $cachedData['size']);
@@ -123,6 +143,26 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
}
+ public function testDeleteWithMountPoints() {
+ $storage2 = new \OC\Files\Storage\Temporary(array());
+ $cache2 = $storage2->getCache();
+ Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
+ Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
+ $this->assertTrue($cache2->inCache('foo.txt'));
+ $folderCachedData = $this->cache->get('folder');
+ $substorageCachedData = $cache2->get('');
+ Filesystem::unlink('folder/substorage/foo.txt');
+ $this->assertFalse($cache2->inCache('foo.txt'));
+
+ $cachedData = $cache2->get('');
+ $this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
+ $this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);
+
+ $cachedData = $this->cache->get('folder');
+ $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
+ $this->assertGreaterThanOrEqual($folderCachedData['mtime'], $cachedData['mtime']);
+ }
+
public function testRename() {
$textSize = strlen("dummy file data\n");
$imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png');
@@ -142,4 +182,85 @@ class Updater extends \PHPUnit_Framework_TestCase {
$this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
$this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
}
+
+ public function testRenameWithMountPoints() {
+ $storage2 = new \OC\Files\Storage\Temporary(array());
+ $cache2 = $storage2->getCache();
+ Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
+ Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
+ $this->assertTrue($cache2->inCache('foo.txt'));
+ $folderCachedData = $this->cache->get('folder');
+ $substorageCachedData = $cache2->get('');
+ $fooCachedData = $cache2->get('foo.txt');
+ Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt');
+ $this->assertFalse($cache2->inCache('foo.txt'));
+ $this->assertTrue($cache2->inCache('bar.txt'));
+ $cachedData = $cache2->get('bar.txt');
+ $this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
+ $mtime = $cachedData['mtime'];
+
+ $cachedData = $cache2->get('');
+ $this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($mtime, $cachedData['mtime']);
+
+ $cachedData = $this->cache->get('folder');
+ $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($mtime, $cachedData['mtime']);
+ }
+
+ public function testTouch() {
+ $rootCachedData = $this->cache->get('');
+ $fooCachedData = $this->cache->get('foo.txt');
+ Filesystem::touch('foo.txt');
+ $cachedData = $this->cache->get('foo.txt');
+ $this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
+ $this->assertGreaterThanOrEqual($fooCachedData['mtime'], $cachedData['mtime']);
+
+ $cachedData = $this->cache->get('');
+ $this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
+ $this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
+ $rootCachedData = $cachedData;
+
+ $time = 1371006070;
+ $barCachedData = $this->cache->get('folder/bar.txt');
+ $folderCachedData = $this->cache->get('folder');
+ Filesystem::touch('folder/bar.txt', $time);
+ $cachedData = $this->cache->get('folder/bar.txt');
+ $this->assertNotEquals($barCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($time, $cachedData['mtime']);
+
+ $cachedData = $this->cache->get('folder');
+ $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($time, $cachedData['mtime']);
+
+ $cachedData = $this->cache->get('');
+ $this->assertNotEquals($rootCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($time, $cachedData['mtime']);
+ }
+
+ public function testTouchWithMountPoints() {
+ $storage2 = new \OC\Files\Storage\Temporary(array());
+ $cache2 = $storage2->getCache();
+ Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
+ Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
+ $this->assertTrue($cache2->inCache('foo.txt'));
+ $folderCachedData = $this->cache->get('folder');
+ $substorageCachedData = $cache2->get('');
+ $fooCachedData = $cache2->get('foo.txt');
+ $cachedData = $cache2->get('foo.txt');
+ $time = 1371006070;
+ Filesystem::touch('folder/substorage/foo.txt', $time);
+ $cachedData = $cache2->get('foo.txt');
+ $this->assertNotEquals($fooCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($time, $cachedData['mtime']);
+
+ $cachedData = $cache2->get('');
+ $this->assertNotEquals($substorageCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($time, $cachedData['mtime']);
+
+ $cachedData = $this->cache->get('folder');
+ $this->assertNotEquals($folderCachedData['etag'], $cachedData['etag']);
+ $this->assertEquals($time, $cachedData['mtime']);
+ }
+
}
diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php
index e43c86ed438..749b1ab75a3 100644
--- a/tests/lib/files/cache/watcher.php
+++ b/tests/lib/files/cache/watcher.php
@@ -29,6 +29,9 @@ class Watcher extends \PHPUnit_Framework_TestCase {
}
}
+ /**
+ * @medium
+ */
function testWatcher() {
$storage = $this->getTestStorage();
$cache = $storage->getCache();
@@ -63,6 +66,9 @@ class Watcher extends \PHPUnit_Framework_TestCase {
$this->assertFalse($cache->inCache('folder/bar2.txt'));
}
+ /**
+ * @medium
+ */
public function testFileToFolder() {
$storage = $this->getTestStorage();
$cache = $storage->getCache();
diff --git a/tests/lib/files/mapper.php b/tests/lib/files/mapper.php
index e3859bc0f23..48ae95b7e72 100644
--- a/tests/lib/files/mapper.php
+++ b/tests/lib/files/mapper.php
@@ -45,8 +45,20 @@ class Mapper extends \PHPUnit_Framework_TestCase {
$this->assertEquals('D:/a/b/text', $this->mapper->slugifyPath('D:/a/b/text'));
// with double dot
- $this->assertEquals('D:/text-text.txt', $this->mapper->slugifyPath('D:/text.text.txt'));
- $this->assertEquals('D:/text-text-2.txt', $this->mapper->slugifyPath('D:/text.text.txt', 2));
- $this->assertEquals('D:/a/b/text-text.txt', $this->mapper->slugifyPath('D:/a/b/text.text.txt'));
+ $this->assertEquals('D:/text.text.txt', $this->mapper->slugifyPath('D:/text.text.txt'));
+ $this->assertEquals('D:/text.text-2.txt', $this->mapper->slugifyPath('D:/text.text.txt', 2));
+ $this->assertEquals('D:/a/b/text.text.txt', $this->mapper->slugifyPath('D:/a/b/text.text.txt'));
+
+ // foldername and filename with periods
+ $this->assertEquals('D:/folder.name.with.periods', $this->mapper->slugifyPath('D:/folder.name.with.periods'));
+ $this->assertEquals('D:/folder.name.with.periods/test-2.txt', $this->mapper->slugifyPath('D:/folder.name.with.periods/test.txt', 2));
+ $this->assertEquals('D:/folder.name.with.periods/test.txt', $this->mapper->slugifyPath('D:/folder.name.with.periods/test.txt'));
+
+ // foldername and filename with periods and spaces
+ $this->assertEquals('D:/folder.name.with.peri-ods', $this->mapper->slugifyPath('D:/folder.name.with.peri ods'));
+ $this->assertEquals('D:/folder.name.with.peri-ods/te-st-2.t-x-t', $this->mapper->slugifyPath('D:/folder.name.with.peri ods/te st.t x t', 2));
+ $this->assertEquals('D:/folder.name.with.peri-ods/te-st.t-x-t', $this->mapper->slugifyPath('D:/folder.name.with.peri ods/te st.t x t'));
+
+
}
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 01f9a9cca11..830913a91ad 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -33,6 +33,9 @@ class View extends \PHPUnit_Framework_TestCase {
}
}
+ /**
+ * @medium
+ */
public function testCacheAPI() {
$storage1 = $this->getTestStorage();
$storage2 = $this->getTestStorage();
@@ -104,6 +107,9 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertEquals(array(), $rootView->getDirectoryContent('/non/existing'));
}
+ /**
+ * @medium
+ */
function testGetPath() {
$storage1 = $this->getTestStorage();
$storage2 = $this->getTestStorage();
@@ -127,6 +133,9 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertNull($folderView->getPath($id1));
}
+ /**
+ * @medium
+ */
function testMountPointOverwrite() {
$storage1 = $this->getTestStorage(false);
$storage2 = $this->getTestStorage();
@@ -170,6 +179,9 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertEquals($textSize, $folderData[0]['size']);
}
+ /**
+ * @medium
+ */
function testSearch() {
$storage1 = $this->getTestStorage();
$storage2 = $this->getTestStorage();
@@ -217,6 +229,9 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertEquals(3, count($folderView->searchByMime('text')));
}
+ /**
+ * @medium
+ */
function testWatcher() {
$storage1 = $this->getTestStorage();
\OC\Files\Filesystem::mount($storage1, array(), '/');
@@ -234,6 +249,9 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertEquals(3, $cachedData['size']);
}
+ /**
+ * @medium
+ */
function testCopyBetweenStorages() {
$storage1 = $this->getTestStorage();
$storage2 = $this->getTestStorage();
@@ -255,6 +273,9 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertTrue($rootView->file_exists('/substorage/folder/bar.txt'));
}
+ /**
+ * @medium
+ */
function testMoveBetweenStorages() {
$storage1 = $this->getTestStorage();
$storage2 = $this->getTestStorage();
@@ -271,6 +292,9 @@ class View extends \PHPUnit_Framework_TestCase {
$this->assertTrue($rootView->file_exists('anotherfolder/bar.txt'));
}
+ /**
+ * @medium
+ */
function testTouch() {
$storage = $this->getTestStorage(true, '\Test\Files\TemporaryNoTouch');
diff --git a/tests/lib/geo.php b/tests/lib/geo.php
index 82e61608687..2c3611c092e 100644
--- a/tests/lib/geo.php
+++ b/tests/lib/geo.php
@@ -7,6 +7,10 @@
*/
class Test_Geo extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @medium
+ */
function testTimezone() {
$result = OC_Geo::timezone(3, 3);
$expected = 'Africa/Porto-Novo';
diff --git a/tests/lib/helper.php b/tests/lib/helper.php
index 336e8f8b3c5..6acb0dfaa6b 100644
--- a/tests/lib/helper.php
+++ b/tests/lib/helper.php
@@ -67,6 +67,15 @@ class Test_Helper extends PHPUnit_Framework_TestCase {
$this->assertEquals($result, $expected);
}
+ function testGetFileNameMimeType() {
+ $this->assertEquals('text/plain', OC_Helper::getFileNameMimeType('foo.txt'));
+ $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.png'));
+ $this->assertEquals('image/png', OC_Helper::getFileNameMimeType('foo.bar.png'));
+ $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('.png'));
+ $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType('foo'));
+ $this->assertEquals('application/octet-stream', OC_Helper::getFileNameMimeType(''));
+ }
+
function testGetStringMimeType() {
$result = OC_Helper::getStringMimeType("/data/data.tar.gz");
$expected = 'text/plain; charset=us-ascii';
diff --git a/tests/phpunit-autotest.xml b/tests/phpunit-autotest.xml
index 577e1f0d490..23b2d6c0060 100644
--- a/tests/phpunit-autotest.xml
+++ b/tests/phpunit-autotest.xml
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
-<phpunit bootstrap="bootstrap.php">
+<phpunit bootstrap="bootstrap.php"
+ strict="true"
+ timeoutForSmallTests="900"
+ timeoutForMediumTests="900"
+ timeoutForLargeTests="900"
+>
<testsuite name='ownCloud'>
<directory suffix='.php'>lib/</directory>
<file>apps.php</file>
@@ -13,13 +18,19 @@
<directory suffix=".php">../3rdparty</directory>
<directory suffix=".php">../apps/files/l10n</directory>
<directory suffix=".php">../apps/files_external/l10n</directory>
+ <directory suffix=".php">../apps/files_external/3rdparty</directory>
<directory suffix=".php">../apps/files_versions/l10n</directory>
<directory suffix=".php">../apps/files_encryption/l10n</directory>
+ <directory suffix=".php">../apps/files_encryption/3rdparty</directory>
<directory suffix=".php">../apps/files_sharing/l10n</directory>
<directory suffix=".php">../apps/files_trashbin/l10n</directory>
<directory suffix=".php">../apps/user_ldap/l10n</directory>
<directory suffix=".php">../apps/user_webdavauth/l10n</directory>
<directory suffix=".php">../lib/MDB2</directory>
+ <directory suffix=".php">../lib/l10n</directory>
+ <directory suffix=".php">../core/l10n</directory>
+ <directory suffix=".php">../settings/l10n</directory>
+ <directory suffix=".php">../tests</directory>
</exclude>
</whitelist>
</filter>