summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/cache/changepropagator.php33
-rw-r--r--tests/lib/files/cache/updaterlegacy.php47
-rw-r--r--tests/lib/files/etagtest.php1
-rw-r--r--tests/lib/notification/notificationtest.php36
4 files changed, 65 insertions, 52 deletions
diff --git a/tests/lib/files/cache/changepropagator.php b/tests/lib/files/cache/changepropagator.php
index 1b56da5e97c..9108330eb9b 100644
--- a/tests/lib/files/cache/changepropagator.php
+++ b/tests/lib/files/cache/changepropagator.php
@@ -94,4 +94,37 @@ class ChangePropagator extends \Test\TestCase {
$this->assertEquals(100, $time - $cache->get('foo')['mtime']);
$this->assertEquals(100, $time - $cache->get('foo/bar')['mtime']);
}
+
+ public function testPropagateCrossStorage() {
+ $storage = new Temporary();
+ $this->view->mkdir('/foo');
+ Filesystem::mount($storage, [], $this->view->getAbsolutePath('/foo/submount'));
+ $this->view->mkdir('/foo/submount/bar');
+ $this->view->file_put_contents('/foo/submount/bar/sad.txt', 'qwerty');
+
+ $oldInfo1 = $this->view->getFileInfo('/');
+ $oldInfo2 = $this->view->getFileInfo('/foo');
+ $oldInfo3 = $this->view->getFileInfo('/foo/submount');
+ $oldInfo4 = $this->view->getFileInfo('/foo/submount/bar');
+
+ $time = time() + 50;
+
+ $this->propagator->addChange('/foo/submount/bar/sad.txt');
+ $this->propagator->propagateChanges($time);
+
+ $newInfo1 = $this->view->getFileInfo('/');
+ $newInfo2 = $this->view->getFileInfo('/foo');
+ $newInfo3 = $this->view->getFileInfo('/foo/submount');
+ $newInfo4 = $this->view->getFileInfo('/foo/submount/bar');
+
+ $this->assertEquals($newInfo1->getMTime(), $time);
+ $this->assertEquals($newInfo2->getMTime(), $time);
+ $this->assertEquals($newInfo3->getMTime(), $time);
+ $this->assertEquals($newInfo4->getMTime(), $time);
+
+ $this->assertNotSame($oldInfo1->getEtag(), $newInfo1->getEtag());
+ $this->assertNotSame($oldInfo2->getEtag(), $newInfo2->getEtag());
+ $this->assertNotSame($oldInfo3->getEtag(), $newInfo3->getEtag());
+ $this->assertNotSame($oldInfo4->getEtag(), $newInfo3->getEtag());
+ }
}
diff --git a/tests/lib/files/cache/updaterlegacy.php b/tests/lib/files/cache/updaterlegacy.php
index f4d52e9a390..c1a0d3d8230 100644
--- a/tests/lib/files/cache/updaterlegacy.php
+++ b/tests/lib/files/cache/updaterlegacy.php
@@ -10,6 +10,7 @@ namespace Test\Files\Cache;
use \OC\Files\Filesystem as Filesystem;
use OC\Files\Storage\Temporary;
+use OC\Files\View;
class UpdaterLegacy extends \Test\TestCase {
/**
@@ -111,7 +112,8 @@ class UpdaterLegacy extends \Test\TestCase {
$storage2->getScanner()->scan(''); //initialize etags
$cache2 = $storage2->getCache();
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
- $folderCachedData = $this->cache->get('folder');
+ $view = new View('/' . self::$user . '/files');
+ $folderCachedData = $view->getFileInfo('folder');
$substorageCachedData = $cache2->get('');
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
$this->assertTrue($cache2->inCache('foo.txt'));
@@ -124,7 +126,7 @@ class UpdaterLegacy extends \Test\TestCase {
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
- $cachedData = $this->cache->get('folder');
+ $cachedData = $view->getFileInfo('folder');
$this->assertInternalType('string', $folderCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
@@ -168,8 +170,9 @@ class UpdaterLegacy extends \Test\TestCase {
$cache2 = $storage2->getCache();
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
+ $view = new View('/' . self::$user . '/files');
$this->assertTrue($cache2->inCache('foo.txt'));
- $folderCachedData = $this->cache->get('folder');
+ $folderCachedData = $view->getFileInfo('folder');
$substorageCachedData = $cache2->get('');
Filesystem::unlink('folder/substorage/foo.txt');
$this->assertFalse($cache2->inCache('foo.txt'));
@@ -180,7 +183,7 @@ class UpdaterLegacy extends \Test\TestCase {
$this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
$this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);
- $cachedData = $this->cache->get('folder');
+ $cachedData = $view->getFileInfo('folder');
$this->assertInternalType('string', $folderCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
@@ -222,8 +225,9 @@ class UpdaterLegacy extends \Test\TestCase {
$cache2 = $storage2->getCache();
Filesystem::mount($storage2, array(), '/' . self::$user . '/files/folder/substorage');
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
+ $view = new View('/' . self::$user . '/files');
$this->assertTrue($cache2->inCache('foo.txt'));
- $folderCachedData = $this->cache->get('folder');
+ $folderCachedData = $view->getFileInfo('folder');
$substorageCachedData = $cache2->get('');
$fooCachedData = $cache2->get('foo.txt');
Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt');
@@ -240,7 +244,7 @@ class UpdaterLegacy extends \Test\TestCase {
// rename can cause mtime change - invalid assert
// $this->assertEquals($mtime, $cachedData['mtime']);
- $cachedData = $this->cache->get('folder');
+ $cachedData = $view->getFileInfo('folder');
$this->assertInternalType('string', $folderCachedData['etag']);
$this->assertInternalType('string', $cachedData['etag']);
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
@@ -287,35 +291,4 @@ class UpdaterLegacy extends \Test\TestCase {
$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;
- $this->cache->put('folder', ['mtime' => $time - 100]);
- Filesystem::touch('folder/substorage/foo.txt', $time);
- $cachedData = $cache2->get('foo.txt');
- $this->assertInternalType('string', $fooCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
- $this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
- $this->assertEquals($time, $cachedData['mtime']);
-
- $cachedData = $cache2->get('');
- $this->assertInternalType('string', $substorageCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
- $this->assertNotSame($substorageCachedData['etag'], $cachedData['etag']);
-
- $cachedData = $this->cache->get('folder');
- $this->assertInternalType('string', $folderCachedData['etag']);
- $this->assertInternalType('string', $cachedData['etag']);
- $this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
- $this->assertEquals($time, $cachedData['mtime']);
- }
-
}
diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php
index 1a11b29cf00..192768d04af 100644
--- a/tests/lib/files/etagtest.php
+++ b/tests/lib/files/etagtest.php
@@ -27,7 +27,6 @@ class EtagTest extends \Test\TestCase {
\OC_Hook::clear('OC_Filesystem', 'setup');
$application = new \OCA\Files_Sharing\AppInfo\Application();
$application->registerMountProviders();
- $application->setupPropagation();
\OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
\OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file');
diff --git a/tests/lib/notification/notificationtest.php b/tests/lib/notification/notificationtest.php
index da3ada440e2..91fa1de8b42 100644
--- a/tests/lib/notification/notificationtest.php
+++ b/tests/lib/notification/notificationtest.php
@@ -176,22 +176,23 @@ class NotificationTest extends TestCase {
public function dataSetObject() {
return [
- ['a', 1],
- [str_repeat('a', 64), time()],
+ ['a', '21', '21'],
+ [str_repeat('a', 64), 42, '42'],
];
}
/**
* @dataProvider dataSetObject
* @param string $type
- * @param int $id
+ * @param int|string $id
+ * @param string $exptectedId
*/
- public function testSetObject($type, $id) {
+ public function testSetObject($type, $id, $exptectedId) {
$this->assertSame('', $this->notification->getObjectType());
- $this->assertSame(0, $this->notification->getObjectId());
+ $this->assertSame('', $this->notification->getObjectId());
$this->assertSame($this->notification, $this->notification->setObject($type, $id));
$this->assertSame($type, $this->notification->getObjectType());
- $this->assertSame($id, $this->notification->getObjectId());
+ $this->assertSame($exptectedId, $this->notification->getObjectId());
}
public function dataSetObjectTypeInvalid() {
@@ -210,7 +211,14 @@ class NotificationTest extends TestCase {
}
public function dataSetObjectIdInvalid() {
- return $this->dataInvalidInt();
+ return [
+ [true],
+ [false],
+ [''],
+ [str_repeat('a', 64 + 1)],
+ [[]],
+ [[str_repeat('a', 64 + 1)]],
+ ];
}
/**
@@ -560,12 +568,12 @@ class NotificationTest extends TestCase {
public function dataIsValidCommon() {
return [
- ['', '', 0, '', 0, false],
- ['app', '', 0, '', 0, false],
- ['app', 'user', 0, '', 0, false],
- ['app', 'user', time(), '', 0, false],
- ['app', 'user', time(), 'type', 0, false],
- ['app', 'user', time(), 'type', 42, true],
+ ['', '', 0, '', '', false],
+ ['app', '', 0, '', '', false],
+ ['app', 'user', 0, '', '', false],
+ ['app', 'user', time(), '', '', false],
+ ['app', 'user', time(), 'type', '', false],
+ ['app', 'user', time(), 'type', '42', true],
];
}
@@ -576,7 +584,7 @@ class NotificationTest extends TestCase {
* @param string $user
* @param int $timestamp
* @param string $objectType
- * @param int $objectId
+ * @param string $objectId
* @param bool $expected
*/
public function testIsValidCommon($app, $user, $timestamp, $objectType, $objectId, $expected) {