mirror of
https://github.com/nextcloud/server.git
synced 2026-11-02 20:11:47 +01:00
61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
namespace Test\Share20;
|
|
|
|
use OC\Share20\Share;
|
|
use OCP\Share\Exceptions\IllegalIDChangeException;
|
|
use OCP\Share\IShare;
|
|
|
|
/**
|
|
* Class ShareTest
|
|
*
|
|
* @package Test\Share20
|
|
*/
|
|
class ShareTest extends \Test\TestCase {
|
|
protected IShare $share;
|
|
|
|
#[\Override]
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
$this->share = $this->createInstanceWithMocks(Share::class);
|
|
}
|
|
|
|
public function testSetIdInt(): void {
|
|
$this->share->setId(42);
|
|
$this->assertEquals('42', $this->share->getId());
|
|
}
|
|
|
|
public function testSetIdString(): void {
|
|
$this->share->setId('foo');
|
|
$this->assertEquals('foo', $this->share->getId());
|
|
}
|
|
|
|
public function testSetIdOnce(): void {
|
|
$this->expectException(IllegalIDChangeException::class);
|
|
$this->expectExceptionMessage('Not allowed to assign a new internal id to a share');
|
|
|
|
$this->share->setId('foo');
|
|
$this->share->setId('bar');
|
|
}
|
|
|
|
public function testSetProviderIdString(): void {
|
|
$this->share->setProviderId('foo');
|
|
$this->share->setId('bar');
|
|
$this->assertEquals('foo:bar', $this->share->getFullId());
|
|
}
|
|
|
|
public function testSetProviderIdOnce(): void {
|
|
$this->expectException(IllegalIDChangeException::class);
|
|
$this->expectExceptionMessage('Not allowed to assign a new provider id to a share');
|
|
|
|
$this->share->setProviderId('foo');
|
|
$this->share->setProviderId('bar');
|
|
}
|
|
}
|