|
|
|
|
@ -19,6 +19,7 @@ use OCP\Share\Events\BeforeShareDeletedEvent; |
|
|
|
|
use OCP\Share\Events\ShareCreatedEvent; |
|
|
|
|
use OCP\Share\IManager; |
|
|
|
|
use OCP\Share\IShare; |
|
|
|
|
use OCP\User\Exceptions\UserNotFoundException; |
|
|
|
|
use PHPUnit\Framework\Attributes\DataProvider; |
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
|
|
|
use Psr\Clock\ClockInterface; |
|
|
|
|
@ -117,6 +118,33 @@ class SharesUpdatedListenerTest extends \Test\TestCase { |
|
|
|
|
$this->sharesUpdatedListener->handle($event); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testShareAddedSkipsUnresolvableUser(): void { |
|
|
|
|
$share = $this->createMock(IShare::class); |
|
|
|
|
$user1 = $this->createUser('user1', ''); |
|
|
|
|
$user2 = $this->createUser('user2', ''); |
|
|
|
|
|
|
|
|
|
$this->manager->method('getUsersForShare') |
|
|
|
|
->willReturn([$user1, $user2]); |
|
|
|
|
|
|
|
|
|
$event = new ShareCreatedEvent($share); |
|
|
|
|
|
|
|
|
|
// user1 is an orphaned recipient that no backend can resolve |
|
|
|
|
$this->shareRecipientUpdater |
|
|
|
|
->expects($this->exactly(2)) |
|
|
|
|
->method('updateForAddedShare') |
|
|
|
|
->willReturnCallback(function (IUser $user) use ($user1): void { |
|
|
|
|
if ($user === $user1) { |
|
|
|
|
throw new UserNotFoundException('Backends provided no user object'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// the failure is logged, not thrown |
|
|
|
|
$this->logger->expects($this->once())->method('debug'); |
|
|
|
|
|
|
|
|
|
// must not throw: user2 is still processed |
|
|
|
|
$this->sharesUpdatedListener->handle($event); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testShareAccessUpdated() { |
|
|
|
|
$user1 = $this->createUser('user1', ''); |
|
|
|
|
$user2 = $this->createUser('user2', ''); |
|
|
|
|
|