summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2015-11-03 07:54:07 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2015-11-05 15:59:09 +0100
commit532b8a1ad0957d7b6413d3f03142082432fb1059 (patch)
tree5ea965cb222652f521781a2464cc4160ab635da1 /tests
parent0be05fdddd06866a55f168d44ad792066235ad96 (diff)
downloadnextcloud-server-532b8a1ad0957d7b6413d3f03142082432fb1059.tar.gz
nextcloud-server-532b8a1ad0957d7b6413d3f03142082432fb1059.zip
Fix oracle
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/share20/defaultshareprovidertest.php154
1 files changed, 119 insertions, 35 deletions
diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php
index c7ce36b6e6b..e99290f6724 100644
--- a/tests/lib/share20/defaultshareprovidertest.php
+++ b/tests/lib/share20/defaultshareprovidertest.php
@@ -76,22 +76,33 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(1),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
- 'permissions' => $qb->expr()->literal(13),
'file_target' => $qb->expr()->literal('myTarget'),
+ 'permissions' => $qb->expr()->literal(13),
]);
$qb->execute();
+ // Get the id
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('id')
+ ->from('share')
+ ->setMaxResults(1)
+ ->orderBy('id', 'DESC')
+ ->execute();
+ $id = $cursor->fetch();
+ $id = $id['id'];
+ $cursor->closeCursor();
+
$storage = $this->getMock('OC\Files\Storage\Storage');
$storage
->expects($this->once())
->method('getOwner')
->willReturn('shareOwner');
- $path = $this->getMock('OCP\Files\Node');
+ $path = $this->getMock('OCP\Files\File');
$path
->expects($this->once())
->method('getStorage')
@@ -113,9 +124,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $shareOwner],
]));
- $share = $this->provider->getShareById(1);
+ $share = $this->provider->getShareById($id);
- $this->assertEquals(1, $share->getId());
+ $this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_USER, $share->getShareType());
$this->assertEquals($sharedWith, $share->getSharedWith());
$this->assertEquals($sharedBy, $share->getSharedBy());
@@ -132,22 +143,33 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(1),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
- 'permissions' => $qb->expr()->literal(13),
'file_target' => $qb->expr()->literal('myTarget'),
+ 'permissions' => $qb->expr()->literal(13),
]);
- $qb->execute();
+ $this->assertEquals(1, $qb->execute());
+
+ // Get the id
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('id')
+ ->from('share')
+ ->setMaxResults(1)
+ ->orderBy('id', 'DESC')
+ ->execute();
+ $id = $cursor->fetch();
+ $id = $id['id'];
+ $cursor->closeCursor();
$storage = $this->getMock('OC\Files\Storage\Storage');
$storage
->expects($this->once())
->method('getOwner')
->willReturn('shareOwner');
- $path = $this->getMock('OCP\Files\Node');
+ $path = $this->getMock('OCP\Files\Folder');
$path
->expects($this->once())
->method('getStorage')
@@ -173,9 +195,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
->with('sharedWith')
->willReturn($sharedWith);
- $share = $this->provider->getShareById(1);
+ $share = $this->provider->getShareById($id);
- $this->assertEquals(1, $share->getId());
+ $this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
$this->assertEquals($sharedWith, $share->getSharedWith());
$this->assertEquals($sharedBy, $share->getSharedBy());
@@ -192,17 +214,28 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(1),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_LINK),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
+ 'file_target' => $qb->expr()->literal('myTarget'),
'permissions' => $qb->expr()->literal(13),
'token' => $qb->expr()->literal('token'),
'expiration' => $qb->expr()->literal('2000-01-02 00:00:00'),
- 'file_target' => $qb->expr()->literal('myTarget'),
]);
- $qb->execute();
+ $this->assertEquals(1, $qb->execute());
+
+ // Get the id
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('id')
+ ->from('share')
+ ->setMaxResults(1)
+ ->orderBy('id', 'DESC')
+ ->execute();
+ $id = $cursor->fetch();
+ $id = $id['id'];
+ $cursor->closeCursor();
$storage = $this->getMock('OC\Files\Storage\Storage');
$storage
@@ -229,9 +262,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $shareOwner],
]));
- $share = $this->provider->getShareById(1);
+ $share = $this->provider->getShareById($id);
- $this->assertEquals(1, $share->getId());
+ $this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_LINK, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals($sharedBy, $share->getSharedBy());
@@ -248,15 +281,27 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(1),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_REMOTE),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
- 'permissions' => $qb->expr()->literal(13),
'file_target' => $qb->expr()->literal('myTarget'),
+ 'permissions' => $qb->expr()->literal(13),
]);
- $qb->execute();
+ $this->assertEquals(1, $qb->execute());
+
+ // Get the id
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('id')
+ ->from('share')
+ ->setMaxResults(1)
+ ->orderBy('id', 'DESC')
+ ->execute();
+ $id = $cursor->fetch();
+ $id = $id['id'];
+ $cursor->closeCursor();
+
$storage = $this->getMock('OC\Files\Storage\Storage');
$storage
@@ -283,9 +328,9 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $shareOwner],
]));
- $share = $this->provider->getShareById(1);
+ $share = $this->provider->getShareById($id);
- $this->assertEquals(1, $share->getId());
+ $this->assertEquals($id, $share->getId());
$this->assertEquals(\OCP\Share::SHARE_TYPE_REMOTE, $share->getShareType());
$this->assertEquals('sharedWith', $share->getSharedWith());
$this->assertEquals($sharedBy, $share->getSharedBy());
@@ -301,14 +346,27 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(1),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
+ 'file_target' => $qb->expr()->literal('myTarget'),
'permissions' => $qb->expr()->literal(13),
]);
- $qb->execute();
+ $this->assertEquals(1, $qb->execute());
+
+ // Get the id
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('id')
+ ->from('share')
+ ->setMaxResults(1)
+ ->orderBy('id', 'DESC')
+ ->execute();
+ $id = $cursor->fetch();
+ $id = $id['id'];
+ $cursor->closeCursor();
+
$path = $this->getMock('OCP\Files\File');
$path
@@ -330,7 +388,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$share = $this->getMock('OC\Share20\IShare');
$share
->method('getId')
- ->willReturn(1);
+ ->willReturn($id);
$share
->expects($this->once())
->method('getShareType')
@@ -375,7 +433,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
\OCP\Util::connectHook('OCP\Share', 'post_unshare', $hookListner, 'listen');
$hookListnerExpects = [
- 'id' => 1,
+ 'id' => $id,
'itemType' => 'file',
'itemSource' => 42,
'shareType' => \OCP\Share::SHARE_TYPE_USER,
@@ -409,41 +467,67 @@ class DefaultShareProviderTest extends \Test\TestCase {
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(1),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
+ 'file_target' => $qb->expr()->literal('myTarget'),
'permissions' => $qb->expr()->literal(13),
]);
- $qb->execute();
+ $this->assertEquals(1, $qb->execute());
+
+ // Get the id
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('id')
+ ->from('share')
+ ->setMaxResults(1)
+ ->orderBy('id', 'DESC')
+ ->execute();
+ $id1 = $cursor->fetch();
+ $id1 = $id1['id'];
+ $cursor->closeCursor();
+
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(2),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
+ 'file_target' => $qb->expr()->literal('myTarget'),
'permissions' => $qb->expr()->literal(13),
- 'parent' => $qb->expr()->literal(1),
+ 'parent' => $qb->expr()->literal($id1),
]);
- $qb->execute();
+ $this->assertEquals(1, $qb->execute());
+
+ // Get the id
+ $qb = $this->dbConn->getQueryBuilder();
+ $cursor = $qb->select('id')
+ ->from('share')
+ ->setMaxResults(1)
+ ->orderBy('id', 'DESC')
+ ->execute();
+ $id2 = $cursor->fetch();
+ $id2 = $id2['id'];
+ $cursor->closeCursor();
+
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('share')
->values([
- 'id' => $qb->expr()->literal(3),
'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER),
'share_with' => $qb->expr()->literal('sharedWith'),
'uid_owner' => $qb->expr()->literal('sharedBy'),
+ 'item_type' => $qb->expr()->literal('file'),
'file_source' => $qb->expr()->literal(42),
+ 'file_target' => $qb->expr()->literal('myTarget'),
'permissions' => $qb->expr()->literal(13),
- 'parent' => $qb->expr()->literal(2),
+ 'parent' => $qb->expr()->literal($id2),
]);
- $qb->execute();
-
+ $this->assertEquals(1, $qb->execute());
$storage = $this->getMock('OC\Files\Storage\Storage');
$storage
@@ -475,7 +559,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
['shareOwner', $shareOwner],
]));
- $share = $this->provider->getShareById(1);
+ $share = $this->provider->getShareById($id1);
$this->provider->delete($share);
$qb = $this->dbConn->getQueryBuilder();