From 2c0cb5a00eb15bfb233bb29de1156e7e35d84743 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 4 Feb 2016 13:28:48 +0100 Subject: [PATCH] Unit test for delete lazy shares --- .../lib/share20/defaultshareprovidertest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/lib/share20/defaultshareprovidertest.php b/tests/lib/share20/defaultshareprovidertest.php index 86b8935161..6002498968 100644 --- a/tests/lib/share20/defaultshareprovidertest.php +++ b/tests/lib/share20/defaultshareprovidertest.php @@ -449,6 +449,39 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEmpty($result); } + public function testDeleteSingleShareLazy() { + $qb = $this->dbConn->getQueryBuilder(); + $qb->insert('share') + ->values([ + 'share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_USER), + 'share_with' => $qb->expr()->literal('sharedWith'), + 'uid_owner' => $qb->expr()->literal('shareOwner'), + 'uid_initiator' => $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), + ]); + $this->assertEquals(1, $qb->execute()); + + $id = $qb->getLastInsertId(); + + $this->rootFolder->expects($this->never())->method($this->anything()); + + $share = $this->provider->getShareById($id); + $this->provider->delete($share); + + $qb = $this->dbConn->getQueryBuilder(); + $qb->select('*') + ->from('share'); + + $cursor = $qb->execute(); + $result = $cursor->fetchAll(); + $cursor->closeCursor(); + + $this->assertEmpty($result); + } + public function testDeleteGroupShareWithUserGroupShares() { $qb = $this->dbConn->getQueryBuilder(); $qb->insert('share')