diff --git a/lib/Provider/TextContextProvider.php b/lib/Provider/TextContextProvider.php index 089cdacb3..11f705734 100644 --- a/lib/Provider/TextContextProvider.php +++ b/lib/Provider/TextContextProvider.php @@ -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, ) { } diff --git a/lib/Provider/TextContextProviderFactory.php b/lib/Provider/TextContextProviderFactory.php index e5223bc53..6f4791fa6 100644 --- a/lib/Provider/TextContextProviderFactory.php +++ b/lib/Provider/TextContextProviderFactory.php @@ -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, ) { } diff --git a/tests/unit/Provider/TextContextProviderFactoryTest.php b/tests/unit/Provider/TextContextProviderFactoryTest.php new file mode 100644 index 000000000..dcb88d139 --- /dev/null +++ b/tests/unit/Provider/TextContextProviderFactoryTest.php @@ -0,0 +1,39 @@ +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()); + } +}