summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-03-08 15:28:45 -0500
committerMichael Gapczynski <mtgap@owncloud.com>2013-03-08 15:28:45 -0500
commitd7beac6d6f3ad588cee6c5ba8a2145b42fa184a2 (patch)
tree613f576938ee8ef88a5a93304a824f60fbb85a7a /tests
parent2ed850e05b46d820528813c2f2415dad60c1c570 (diff)
parent546fb72b25fb8ebdc70aa75ccc7a095d7d83b174 (diff)
downloadnextcloud-server-d7beac6d6f3ad588cee6c5ba8a2145b42fa184a2.tar.gz
nextcloud-server-d7beac6d6f3ad588cee6c5ba8a2145b42fa184a2.zip
Merge branch 'master' into filecache_mtime
Conflicts: lib/files/view.php lib/util.php tests/lib/files/cache/cache.php
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/app.php74
-rw-r--r--tests/lib/dbschema.php12
-rw-r--r--tests/lib/files/cache/cache.php18
-rw-r--r--tests/lib/files/mount.php21
-rw-r--r--tests/lib/files/storage/mappedlocalwithdotteddatadir.php42
-rw-r--r--tests/lib/files/storage/storage.php16
-rw-r--r--tests/lib/share/share.php5
-rw-r--r--tests/lib/util.php5
8 files changed, 185 insertions, 8 deletions
diff --git a/tests/lib/app.php b/tests/lib/app.php
new file mode 100644
index 00000000000..c452d752c9f
--- /dev/null
+++ b/tests/lib/app.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Copyright (c) 2012 Bernhard Posselt <nukeawhale@gmail.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+class Test_App extends PHPUnit_Framework_TestCase {
+
+
+ public function testIsAppVersionCompatibleSingleOCNumber(){
+ $oc = array(4);
+ $app = '4.0';
+
+ $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+
+ public function testIsAppVersionCompatibleMultipleOCNumber(){
+ $oc = array(4, 3, 1);
+ $app = '4.3';
+
+ $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+
+ public function testIsAppVersionCompatibleSingleNumber(){
+ $oc = array(4);
+ $app = '4';
+
+ $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+
+ public function testIsAppVersionCompatibleSingleAppNumber(){
+ $oc = array(4, 3);
+ $app = '4';
+
+ $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+
+ public function testIsAppVersionCompatibleComplex(){
+ $oc = array(5, 0, 0);
+ $app = '4.5.1';
+
+ $this->assertTrue(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+
+ public function testIsAppVersionCompatibleShouldFail(){
+ $oc = array(4, 3, 1);
+ $app = '4.3.2';
+
+ $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+ public function testIsAppVersionCompatibleShouldFailTwoVersionNumbers(){
+ $oc = array(4, 3, 1);
+ $app = '4.4';
+
+ $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+
+ public function testIsAppVersionCompatibleShouldFailOneVersionNumbers(){
+ $oc = array(4, 3, 1);
+ $app = '5';
+
+ $this->assertFalse(OC_App::isAppVersionCompatible($oc, $app));
+ }
+
+} \ No newline at end of file
diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php
index fb60ce7dbb7..e20a04ef7fd 100644
--- a/tests/lib/dbschema.php
+++ b/tests/lib/dbschema.php
@@ -91,9 +91,15 @@ 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_%' "
- . "AND schemaname != 'information_schema' "
- . "AND tablename = '".$table."'";
+ . "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 'mssql':
+ $sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '{$table}'";
$query = OC_DB::prepare($sql);
$result = $query->execute(array());
$exists = $result && $result->fetchOne();
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index 794664c8893..edcd1c487d0 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -8,6 +8,12 @@
namespace Test\Files\Cache;
+class LongId extends \OC\Files\Storage\Temporary {
+ public function getId() {
+ return 'long:' . str_repeat('foo', 50) . parent::getId();
+ }
+}
+
class Cache extends \PHPUnit_Framework_TestCase {
/**
* @var \OC\Files\Storage\Temporary $storage;
@@ -221,6 +227,15 @@ class Cache extends \PHPUnit_Framework_TestCase {
$this->assertEquals(25, $cachedData['mtime']);
}
+ function testLongId() {
+ $storage = new LongId(array());
+ $cache = $storage->getCache();
+ $storageId = $storage->getId();
+ $data = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file');
+ $id = $cache->put('foo', $data);
+ $this->assertEquals(array(md5($storageId), 'foo'), \OC\Files\Cache\Cache::getById($id));
+ }
+
public function tearDown() {
$this->cache->clear();
}
@@ -229,5 +244,4 @@ class Cache extends \PHPUnit_Framework_TestCase {
$this->storage = new \OC\Files\Storage\Temporary(array());
$this->cache = new \OC\Files\Cache\Cache($this->storage);
}
-}
-
+} \ No newline at end of file
diff --git a/tests/lib/files/mount.php b/tests/lib/files/mount.php
index f223f0f6c53..a3dc06cc668 100644
--- a/tests/lib/files/mount.php
+++ b/tests/lib/files/mount.php
@@ -10,6 +10,12 @@ namespace Test\Files;
use \OC\Files\Storage\Temporary;
+class LongId extends Temporary {
+ public function getId() {
+ return 'long:' . str_repeat('foo', 50) . parent::getId();
+ }
+}
+
class Mount extends \PHPUnit_Framework_TestCase {
public function setup() {
\OC_Util::setupFS();
@@ -33,9 +39,20 @@ class Mount extends \PHPUnit_Framework_TestCase {
$this->assertEquals(2, count(\OC\Files\Mount::findIn('/')));
$id = $mount->getStorageId();
- $this->assertEquals(array($mount), \OC\Files\Mount::findById($id));
+ $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($id));
$mount2 = new \OC\Files\Mount($storage, '/foo/bar');
- $this->assertEquals(array($mount, $mount2), \OC\Files\Mount::findById($id));
+ $this->assertEquals(array($mount, $mount2), \OC\Files\Mount::findByStorageId($id));
+ }
+
+ public function testLong() {
+ $storage = new LongId(array());
+ $mount = new \OC\Files\Mount($storage, '/foo');
+
+ $id = $mount->getStorageId();
+ $storageId = $storage->getId();
+ $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($id));
+ $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId($storageId));
+ $this->assertEquals(array($mount), \OC\Files\Mount::findByStorageId(md5($storageId)));
}
}
diff --git a/tests/lib/files/storage/mappedlocalwithdotteddatadir.php b/tests/lib/files/storage/mappedlocalwithdotteddatadir.php
new file mode 100644
index 00000000000..d2e5e2e97af
--- /dev/null
+++ b/tests/lib/files/storage/mappedlocalwithdotteddatadir.php
@@ -0,0 +1,42 @@
+<?php
+/**
+* ownCloud
+*
+* @author Robin Appelman
+* @copyright 2012 Robin Appelman icewind@owncloud.com
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+* License as published by the Free Software Foundation; either
+* version 3 of the License, or any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+*
+* You should have received a copy of the GNU Affero General Public
+* License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+namespace Test\Files\Storage;
+
+class MappedLocalWithDottedDataDir extends Storage {
+ /**
+ * @var string tmpDir
+ */
+ private $tmpDir;
+
+ public function setUp() {
+ $this->tmpDir = \OC_Helper::tmpFolder().'dir.123'.DIRECTORY_SEPARATOR;
+ mkdir($this->tmpDir);
+ $this->instance=new \OC\Files\Storage\MappedLocal(array('datadir'=>$this->tmpDir));
+ }
+
+ public function tearDown() {
+ \OC_Helper::rmdirr($this->tmpDir);
+ unset($this->instance);
+ }
+}
+
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index c74a16f509f..f78f66d8b8a 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -223,6 +223,22 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
$this->assertContains('/logo-wide.png', $result);
}
+ public function testSearchInSubFolder() {
+ $this->instance->mkdir('sub')
+ ;
+ $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
+ $this->instance->file_put_contents('/sub/lorem.txt', file_get_contents($textFile, 'r'));
+ $pngFile = \OC::$SERVERROOT . '/tests/data/logo-wide.png';
+ $this->instance->file_put_contents('/sub/logo-wide.png', file_get_contents($pngFile, 'r'));
+ $svgFile = \OC::$SERVERROOT . '/tests/data/logo-wide.svg';
+ $this->instance->file_put_contents('/sub/logo-wide.svg', file_get_contents($svgFile, 'r'));
+
+ $result = $this->instance->search('logo');
+ $this->assertEquals(2, count($result));
+ $this->assertContains('/sub/logo-wide.svg', $result);
+ $this->assertContains('/sub/logo-wide.png', $result);
+ }
+
public function testFOpen() {
$textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php
index ab43e47726b..e7d441a7e78 100644
--- a/tests/lib/share/share.php
+++ b/tests/lib/share/share.php
@@ -28,7 +28,7 @@ class Test_Share extends PHPUnit_Framework_TestCase {
protected $groupBackend;
protected $group1;
protected $group2;
-
+ protected $resharing;
public function setUp() {
OC_User::clearBackends();
@@ -56,11 +56,14 @@ class Test_Share extends PHPUnit_Framework_TestCase {
OCP\Share::registerBackend('test', 'Test_Share_Backend');
OC_Hook::clear('OCP\\Share');
OC::registerShareHooks();
+ $this->resharing = OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes');
+ OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
}
public function tearDown() {
$query = OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `item_type` = ?');
$query->execute(array('test'));
+ OC_Appconfig::setValue('core', 'shareapi_allow_resharing', $this->resharing);
}
public function testShareInvalidShareType() {
diff --git a/tests/lib/util.php b/tests/lib/util.php
index ebff3c7381a..b904c359807 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -42,4 +42,9 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$result = strlen(OC_Util::generate_random_bytes(59));
$this->assertEquals(59, $result);
}
+
+ function testGetDefaultEmailAddress() {
+ $email = \OCP\Util::getDefaultEmailAddress("no-reply");
+ $this->assertEquals('no-reply@localhost.localdomain', $email);
+ }
} \ No newline at end of file