0
0
mirror of https://github.com/nextcloud/server.git synced 2024-12-29 00:18:42 +00:00
nextcloud_server/apps/federatedfilesharing/tests/TokenHandlerTest.php
Christoph Wurst 49dd79eabb
refactor: Add void return type to PHPUnit test methods
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
2024-09-15 22:32:31 +02:00

43 lines
1.0 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 OCA\FederatedFileSharing\Tests;
use OCA\FederatedFileSharing\TokenHandler;
use OCP\Security\ISecureRandom;
class TokenHandlerTest extends \Test\TestCase {
/** @var TokenHandler */
private $tokenHandler;
/** @var ISecureRandom | \PHPUnit\Framework\MockObject\MockObject */
private $secureRandom;
/** @var int */
private $expectedTokenLength = 15;
protected function setUp(): void {
parent::setUp();
$this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->getMock();
$this->tokenHandler = new TokenHandler($this->secureRandom);
}
public function testGenerateToken(): void {
$this->secureRandom->expects($this->once())->method('generate')
->with(
$this->expectedTokenLength,
ISecureRandom::CHAR_ALPHANUMERIC
)
->willReturn('mytoken');
$this->assertSame('mytoken', $this->tokenHandler->generateToken());
}
}