Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Provider/TextContextProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
private readonly CardService $cardService,
private readonly CardMapper $cardMapper,
private readonly PermissionService $permissionService,
private readonly string $userId,
private readonly ?string $userId,
private readonly int $cardId,
) {
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Provider/TextContextProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
private readonly CardService $cardService,
private readonly CardMapper $cardMapper,
private readonly PermissionService $permissionService,
private readonly string $userId,
private readonly ?string $userId,
) {
}

Expand Down
39 changes: 39 additions & 0 deletions tests/unit/Provider/TextContextProviderFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Deck\Provider;

use OC\Security\SecureRandom;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\PermissionService;
use OCA\Text\Context\IContext;
use PHPUnit\Framework\TestCase;

class TextContextProviderFactoryTest extends TestCase {
protected function setUp(): void {
parent::setUp();
if (!interface_exists(IContext::class)) {
$this->markTestSkipped('Text app not available');
}
}

/**
* Text dispatches its context event on public share requests too, where there is no user
*/
public function testBuildForCardWithoutUser(): void {
$factory = new TextContextProviderFactory(
$this->createMock(SecureRandom::class),
$this->createMock(CardService::class),
$this->createMock(CardMapper::class),
$this->createMock(PermissionService::class),
null,
);

$this->assertSame(5, $factory->buildForCard(5)->getId());
}
}