aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2021-04-23 09:12:12 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2023-09-02 10:25:24 +0200
commitf828dce5972ee633129b97aa267870206a8057b8 (patch)
tree24a11f3aa891a1462e80533ac624d07442ff51e8 /tests
parent12f57ada7dd8316ef205b09aa8eaaadf0fcafefc (diff)
downloadnextcloud-server-f828dce5972ee633129b97aa267870206a8057b8.tar.gz
nextcloud-server-f828dce5972ee633129b97aa267870206a8057b8.zip
Fix sharing creation insert and get
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/ViewTest.php2
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php33
2 files changed, 17 insertions, 18 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 2bf483df7d7..1c22541af92 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -1689,8 +1689,6 @@ class ViewTest extends \Test\TestCase {
->setSharedBy($this->user)
->setShareType(IShare::TYPE_USER)
->setPermissions(\OCP\Constants::PERMISSION_READ)
- ->setId(42)
- ->setProviderId('foo')
->setNode($shareDir);
$shareManager->createShare($share);
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 0a6f106a5db..0ce96102a30 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -24,12 +24,12 @@ namespace Test\Share20;
use OC\Share20\DefaultShareProvider;
use OC\Share20\ShareAttributes;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Defaults;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
-use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IGroup;
use OCP\IGroupManager;
@@ -79,8 +79,8 @@ class DefaultShareProviderTest extends \Test\TestCase {
/** @var \PHPUnit\Framework\MockObject\MockObject|IURLGenerator */
protected $urlGenerator;
- /** @var IConfig|MockObject */
- protected $config;
+ /** @var ITimeFactory|MockObject */
+ protected $timeFactory;
protected function setUp(): void {
$this->dbConn = \OC::$server->getDatabaseConnection();
@@ -92,9 +92,10 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->l10n = $this->createMock(IL10N::class);
$this->defaults = $this->getMockBuilder(Defaults::class)->disableOriginalConstructor()->getMock();
$this->urlGenerator = $this->createMock(IURLGenerator::class);
- $this->config = $this->createMock(IConfig::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
$this->userManager->expects($this->any())->method('userExists')->willReturn(true);
+ $this->timeFactory->expects($this->any())->method('now')->willReturn(new \DateTimeImmutable("2023-05-04 00:00 Europe/Berlin"));
//Empty share table
$this->dbConn->getQueryBuilder()->delete('share')->execute();
@@ -108,7 +109,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
}
@@ -469,7 +470,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
])
->setMethods(['getShareById'])
->getMock();
@@ -564,7 +565,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
])
->setMethods(['getShareById'])
->getMock();
@@ -724,11 +725,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
$this->assertSame($path, $share2->getNode());
- // nothing from setSharedWithDisplayName/setSharedWithAvatar is saved in DB
+ // Data is kept after creation
$this->assertSame('Displayed Name', $share->getSharedWithDisplayName());
$this->assertSame('/path/to/image.svg', $share->getSharedWithAvatar());
- $this->assertSame(null, $share2->getSharedWithDisplayName());
- $this->assertSame(null, $share2->getSharedWithAvatar());
+ $this->assertSame('Displayed Name', $share2->getSharedWithDisplayName());
+ $this->assertSame('/path/to/image.svg', $share2->getSharedWithAvatar());
$this->assertSame(
[
@@ -794,11 +795,11 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->assertLessThanOrEqual(new \DateTime(), $share2->getShareTime());
$this->assertSame($path, $share2->getNode());
- // nothing from setSharedWithDisplayName/setSharedWithAvatar is saved in DB
+ // Data is kept after creation
$this->assertSame('Displayed Name', $share->getSharedWithDisplayName());
$this->assertSame('/path/to/image.svg', $share->getSharedWithAvatar());
- $this->assertSame(null, $share2->getSharedWithDisplayName());
- $this->assertSame(null, $share2->getSharedWithAvatar());
+ $this->assertSame('Displayed Name', $share2->getSharedWithDisplayName());
+ $this->assertSame('/path/to/image.svg', $share2->getSharedWithAvatar());
$this->assertSame(
[
@@ -2524,7 +2525,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
$password = md5(time());
@@ -2622,7 +2623,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
$u1 = $userManager->createUser('testShare1', 'test');
@@ -2718,7 +2719,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
$this->defaults,
$this->l10nFactory,
$this->urlGenerator,
- $this->config
+ $this->timeFactory
);
$u1 = $userManager->createUser('testShare1', 'test');