mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
chore: run rector on tests
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
de74745ab6
commit
29e39c0a2e
250 changed files with 1864 additions and 1494 deletions
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
namespace Tests\Core\Command\Config;
|
||||
|
||||
use OC\Core\Command\App\Disable;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\Server;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -25,13 +27,13 @@ class AppsDisableTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$command = new Disable(
|
||||
\OC::$server->getAppManager()
|
||||
Server::get(IAppManager::class)
|
||||
);
|
||||
|
||||
$this->commandTester = new CommandTester($command);
|
||||
|
||||
\OC::$server->getAppManager()->enableApp('admin_audit');
|
||||
\OC::$server->getAppManager()->enableApp('comments');
|
||||
Server::get(IAppManager::class)->enableApp('admin_audit');
|
||||
Server::get(IAppManager::class)->enableApp('comments');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ namespace Tests\Core\Command\Config;
|
|||
|
||||
use OC\Core\Command\App\Enable;
|
||||
use OC\Installer;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\Server;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -26,15 +29,15 @@ class AppsEnableTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$command = new Enable(
|
||||
\OC::$server->getAppManager(),
|
||||
\OC::$server->getGroupManager(),
|
||||
\OC::$server->get(Installer::class),
|
||||
Server::get(IAppManager::class),
|
||||
Server::get(IGroupManager::class),
|
||||
Server::get(Installer::class),
|
||||
);
|
||||
|
||||
$this->commandTester = new CommandTester($command);
|
||||
|
||||
\OC::$server->getAppManager()->disableApp('admin_audit');
|
||||
\OC::$server->getAppManager()->disableApp('comments');
|
||||
Server::get(IAppManager::class)->disableApp('admin_audit');
|
||||
Server::get(IAppManager::class)->disableApp('comments');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
namespace Tests\Core\Command\Encryption;
|
||||
|
||||
use OC\Core\Command\Encryption\ChangeKeyStorageRoot;
|
||||
use OC\Encryption\Keys\Storage;
|
||||
use OC\Encryption\Util;
|
||||
use OC\Files\View;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -157,7 +158,7 @@ class ChangeKeyStorageRootTest extends TestCase {
|
|||
->willReturn(true);
|
||||
|
||||
$this->view->expects($this->once())->method('file_put_contents')
|
||||
->with('newRoot/' . \OC\Encryption\Keys\Storage::KEY_STORAGE_MARKER,
|
||||
->with('newRoot/' . Storage::KEY_STORAGE_MARKER,
|
||||
'Nextcloud will detect this folder as key storage root only if this file exists')->willReturn(true);
|
||||
|
||||
$this->invokePrivate($this->changeKeyStorageRoot, 'prepareNewRoot', ['newRoot']);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class DecryptAllTest extends TestCase {
|
|||
];
|
||||
$this->config->expects($this->exactly(2))
|
||||
->method('setSystemValue')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -137,7 +137,7 @@ class DecryptAllTest extends TestCase {
|
|||
];
|
||||
$this->config->expects($this->exactly(2))
|
||||
->method('setAppValue')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -188,7 +188,7 @@ class DecryptAllTest extends TestCase {
|
|||
];
|
||||
$this->config->expects($this->exactly(2))
|
||||
->method('setAppValue')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -208,7 +208,7 @@ class DecryptAllTest extends TestCase {
|
|||
$this->decryptAll->expects($this->once())
|
||||
->method('decryptAll')
|
||||
->with($this->consoleInput, $this->consoleOutput, 'user1')
|
||||
->willReturnCallback(function () {
|
||||
->willReturnCallback(function (): void {
|
||||
throw new \Exception();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ class SetDefaultModuleTest extends TestCase {
|
|||
];
|
||||
$this->consoleOutput->expects($this->exactly(2))
|
||||
->method('writeln')
|
||||
->willReturnCallback(function ($message) use (&$calls) {
|
||||
->willReturnCallback(function ($message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertStringContainsString($expected, $message);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class FileTest extends TestCase {
|
|||
];
|
||||
$this->consoleOutput->expects($this->exactly(3))
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) use (&$calls) {
|
||||
->willReturnCallback(function (string $message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected[0], $message);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ class UpdateDBTest extends TestCase {
|
|||
];
|
||||
$this->consoleOutput->expects($this->exactly(2))
|
||||
->method('writeln')
|
||||
->willReturnCallback(function ($message) use (&$calls) {
|
||||
->willReturnCallback(function ($message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertStringContainsString($expected, $message);
|
||||
});
|
||||
|
|
@ -110,7 +110,7 @@ class UpdateDBTest extends TestCase {
|
|||
];
|
||||
$this->consoleOutput->expects($this->exactly(4))
|
||||
->method('writeln')
|
||||
->willReturnCallback(function ($message) use (&$calls) {
|
||||
->willReturnCallback(function ($message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertStringContainsString($expected, $message);
|
||||
});
|
||||
|
|
@ -163,7 +163,7 @@ class UpdateDBTest extends TestCase {
|
|||
];
|
||||
$this->consoleOutput->expects($this->exactly(3))
|
||||
->method('writeln')
|
||||
->willReturnCallback(function ($message) use (&$calls) {
|
||||
->willReturnCallback(function ($message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertStringContainsString($expected, $message);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class RepairTest extends TestCase {
|
|||
->willReturn($outputFormatter);
|
||||
$this->output->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function ($line) use ($self) {
|
||||
->willReturnCallback(function ($line) use ($self): void {
|
||||
$self->outputLines .= $line . "\n";
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ class AddTest extends TestCase {
|
|||
$tag->method('getAccessLevel')->willReturn(ISystemTag::ACCESS_LEVEL_PUBLIC);
|
||||
|
||||
$this->systemTagManager->method('createTag')
|
||||
->willReturnCallback(function ($tagName, $userVisible, $userAssignable) {
|
||||
->willReturnCallback(function ($tagName, $userVisible, $userAssignable): void {
|
||||
throw new TagAlreadyExistsException(
|
||||
'Tag ("' . $tagName . '", ' . $userVisible . ', ' . $userAssignable . ') already exists'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class DeleteTest extends TestCase {
|
|||
});
|
||||
|
||||
$this->systemTagManager->method('deleteTags')
|
||||
->willReturnCallback(function ($tagId) {
|
||||
->willReturnCallback(function ($tagId): void {
|
||||
throw new TagNotFoundException();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class EditTest extends TestCase {
|
|||
});
|
||||
|
||||
$this->systemTagManager->method('updateTag')
|
||||
->willReturnCallback(function ($tagId, $tagName, $userVisible, $userAssignable) {
|
||||
->willReturnCallback(function ($tagId, $tagName, $userVisible, $userAssignable): void {
|
||||
throw new TagAlreadyExistsException(
|
||||
'Tag ("' . $tagName . '", ' . $userVisible . ', ' . $userAssignable . ') already exists'
|
||||
);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ use OCA\OAuth2\Db\AccessTokenMapper;
|
|||
use OCA\OAuth2\Db\Client;
|
||||
use OCA\OAuth2\Db\ClientMapper;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\Http\StandaloneTemplateResponse;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Defaults;
|
||||
|
|
@ -168,7 +171,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
],
|
||||
'guest'
|
||||
);
|
||||
$csp = new Http\ContentSecurityPolicy();
|
||||
$csp = new ContentSecurityPolicy();
|
||||
$csp->addAllowedFormActionDomain('nc://*');
|
||||
$expected->setContentSecurityPolicy($csp);
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage());
|
||||
|
|
@ -235,7 +238,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
],
|
||||
'guest'
|
||||
);
|
||||
$csp = new Http\ContentSecurityPolicy();
|
||||
$csp = new ContentSecurityPolicy();
|
||||
$csp->addAllowedFormActionDomain('https://example.com/redirect.php');
|
||||
$expected->setContentSecurityPolicy($csp);
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->showAuthPickerPage('MyClientIdentifier'));
|
||||
|
|
@ -279,7 +282,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
->method('getId')
|
||||
->willThrowException(new SessionNotAvailableException());
|
||||
|
||||
$expected = new Http\Response();
|
||||
$expected = new Response();
|
||||
$expected->setStatus(Http::STATUS_FORBIDDEN);
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||
}
|
||||
|
|
@ -304,7 +307,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
->with('SessionId')
|
||||
->willThrowException(new InvalidTokenException());
|
||||
|
||||
$expected = new Http\Response();
|
||||
$expected = new Response();
|
||||
$expected->setStatus(Http::STATUS_FORBIDDEN);
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||
}
|
||||
|
|
@ -380,7 +383,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
$this->eventDispatcher->expects($this->once())
|
||||
->method('dispatchTyped');
|
||||
|
||||
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||
$expected = new RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||
}
|
||||
|
||||
|
|
@ -406,7 +409,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
];
|
||||
$this->session
|
||||
->method('remove')
|
||||
->willReturnCallback(function ($key) use (&$calls) {
|
||||
->willReturnCallback(function ($key) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, $key);
|
||||
});
|
||||
|
|
@ -470,7 +473,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
$this->eventDispatcher->expects($this->once())
|
||||
->method('dispatchTyped');
|
||||
|
||||
$expected = new Http\RedirectResponse($redirectUrl);
|
||||
$expected = new RedirectResponse($redirectUrl);
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken', 'MyClientIdentifier'));
|
||||
}
|
||||
|
||||
|
|
@ -545,7 +548,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
$this->eventDispatcher->expects($this->once())
|
||||
->method('dispatchTyped');
|
||||
|
||||
$expected = new Http\RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||
$expected = new RedirectResponse('nc://login/server:http://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||
}
|
||||
|
||||
|
|
@ -676,7 +679,7 @@ class ClientFlowLoginControllerTest extends TestCase {
|
|||
$this->eventDispatcher->expects($this->once())
|
||||
->method('dispatchTyped');
|
||||
|
||||
$expected = new Http\RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||
$expected = new RedirectResponse('nc://login/server:' . $expected . '://example.com&user:MyLoginName&password:MyGeneratedToken');
|
||||
$this->assertEquals($expected, $this->clientFlowLoginController->generateAppPassword('MyStateToken'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ use OC\Core\Exception\LoginFlowV2ClientForbiddenException;
|
|||
use OC\Core\Exception\LoginFlowV2NotFoundException;
|
||||
use OC\Core\Service\LoginFlowV2Service;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\RedirectResponse;
|
||||
use OCP\AppFramework\Http\StandaloneTemplateResponse;
|
||||
use OCP\Defaults;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
|
|
@ -111,7 +113,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase {
|
|||
$result = $this->controller->landing('token');
|
||||
|
||||
$this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus());
|
||||
$this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result);
|
||||
$this->assertInstanceOf(StandaloneTemplateResponse::class, $result);
|
||||
}
|
||||
|
||||
public function testLandingValid(): void {
|
||||
|
|
@ -129,7 +131,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase {
|
|||
|
||||
$result = $this->controller->landing('token');
|
||||
|
||||
$this->assertInstanceOf(Http\RedirectResponse::class, $result);
|
||||
$this->assertInstanceOf(RedirectResponse::class, $result);
|
||||
$this->assertSame(Http::STATUS_SEE_OTHER, $result->getStatus());
|
||||
$this->assertSame('https://server/path', $result->getRedirectURL());
|
||||
}
|
||||
|
|
@ -168,7 +170,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase {
|
|||
|
||||
$result = $this->controller->showAuthPickerPage();
|
||||
|
||||
$this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result);
|
||||
$this->assertInstanceOf(StandaloneTemplateResponse::class, $result);
|
||||
$this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus());
|
||||
$this->assertSame('Please use original client', $result->getParams()['message']);
|
||||
}
|
||||
|
|
@ -247,7 +249,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase {
|
|||
|
||||
$result = $this->controller->grantPage('stateToken');
|
||||
|
||||
$this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result);
|
||||
$this->assertInstanceOf(StandaloneTemplateResponse::class, $result);
|
||||
$this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus());
|
||||
$this->assertSame('Please use original client', $result->getParams()['message']);
|
||||
}
|
||||
|
|
@ -330,7 +332,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase {
|
|||
|
||||
$result = $this->controller->generateAppPassword('stateToken');
|
||||
|
||||
$this->assertInstanceOf(Http\StandaloneTemplateResponse::class, $result);
|
||||
$this->assertInstanceOf(StandaloneTemplateResponse::class, $result);
|
||||
$this->assertSame(Http::STATUS_FORBIDDEN, $result->getStatus());
|
||||
$this->assertSame('Please use original client', $result->getParams()['message']);
|
||||
}
|
||||
|
|
@ -355,7 +357,7 @@ class ClientFlowLoginV2ControllerTest extends TestCase {
|
|||
$clearedState = false;
|
||||
$clearedLogin = false;
|
||||
$this->session->method('remove')
|
||||
->willReturnCallback(function ($name) use (&$clearedLogin, &$clearedState) {
|
||||
->willReturnCallback(function ($name) use (&$clearedLogin, &$clearedState): void {
|
||||
if ($name === 'client.flow.v2.state.token') {
|
||||
$clearedState = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ class LoginControllerTest extends TestCase {
|
|||
];
|
||||
$this->initialState->expects($this->exactly(13))
|
||||
->method('provideInitialState')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
if (!empty($expected)) {
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
|
|
@ -316,7 +316,7 @@ class LoginControllerTest extends TestCase {
|
|||
];
|
||||
$this->initialState->expects($this->exactly(14))
|
||||
->method('provideInitialState')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
if (!empty($expected)) {
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
|
|
@ -396,7 +396,7 @@ class LoginControllerTest extends TestCase {
|
|||
];
|
||||
$this->initialState->expects($this->exactly(13))
|
||||
->method('provideInitialState')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
if (!empty($expected)) {
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
|
|
@ -459,7 +459,7 @@ class LoginControllerTest extends TestCase {
|
|||
];
|
||||
$this->initialState->expects($this->exactly(13))
|
||||
->method('provideInitialState')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
if (!empty($expected)) {
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ class LostControllerTest extends TestCase {
|
|||
$this->initialState
|
||||
->expects($this->exactly(2))
|
||||
->method('provideInitialState')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -461,7 +461,7 @@ class LostControllerTest extends TestCase {
|
|||
$this->eventDispatcher
|
||||
->expects($this->exactly(2))
|
||||
->method('dispatchTyped')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use OCP\IRequest;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Server;
|
||||
use OCP\ServerVersion;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ class OCSControllerTest extends TestCase {
|
|||
$this->userSession = $this->createMock(IUserSession::class);
|
||||
$this->userManager = $this->createMock(IUserManager::class);
|
||||
$this->keyManager = $this->createMock(Manager::class);
|
||||
$serverVersion = \OCP\Server::get(ServerVersion::class);
|
||||
$serverVersion = Server::get(ServerVersion::class);
|
||||
|
||||
$this->controller = new OCSController(
|
||||
'core',
|
||||
|
|
@ -78,7 +79,7 @@ class OCSControllerTest extends TestCase {
|
|||
->method('isLoggedIn')
|
||||
->willReturn(true);
|
||||
|
||||
$serverVersion = \OCP\Server::get(ServerVersion::class);
|
||||
$serverVersion = Server::get(ServerVersion::class);
|
||||
|
||||
$result = [];
|
||||
$result['version'] = [
|
||||
|
|
@ -111,7 +112,7 @@ class OCSControllerTest extends TestCase {
|
|||
$this->userSession->expects($this->once())
|
||||
->method('isLoggedIn')
|
||||
->willReturn(false);
|
||||
$serverVersion = \OCP\Server::get(ServerVersion::class);
|
||||
$serverVersion = Server::get(ServerVersion::class);
|
||||
|
||||
$result = [];
|
||||
$result['version'] = [
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
|
|||
];
|
||||
$this->session->expects($this->exactly(2))
|
||||
->method('set')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ use OCP\L10N\IFactory;
|
|||
use OCP\Mail\IMailer;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Security\VerificationToken\IVerificationToken;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
|
@ -61,7 +62,7 @@ class AccountManagerTest extends TestCase {
|
|||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->connection = \OCP\Server::get(IDBConnection::class);
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->phoneNumberUtil = new PhoneNumberUtil();
|
||||
|
||||
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
||||
|
|
@ -488,7 +489,7 @@ class AccountManagerTest extends TestCase {
|
|||
} else {
|
||||
$this->eventDispatcher->expects($this->once())->method('dispatchTyped')
|
||||
->willReturnCallback(
|
||||
function ($event) use ($user, $newData) {
|
||||
function ($event) use ($user, $newData): void {
|
||||
$this->assertInstanceOf(UserUpdatedEvent::class, $event);
|
||||
$this->assertSame($user, $event->getUser());
|
||||
$this->assertSame($newData, $event->getData());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
namespace Test\Activity;
|
||||
|
||||
use OCP\Activity\Exceptions\IncompleteActivityException;
|
||||
use OCP\Activity\IConsumer;
|
||||
use OCP\Activity\IEvent;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
|
|
@ -228,7 +230,7 @@ class ManagerTest extends TestCase {
|
|||
$consumer->expects($this->once())
|
||||
->method('receive')
|
||||
->with($event)
|
||||
->willReturnCallback(function (\OCP\Activity\IEvent $event) use ($expected) {
|
||||
->willReturnCallback(function (IEvent $event) use ($expected): void {
|
||||
$this->assertLessThanOrEqual(time() + 2, $event->getTimestamp(), 'Timestamp not set correctly');
|
||||
$this->assertGreaterThanOrEqual(time() - 2, $event->getTimestamp(), 'Timestamp not set correctly');
|
||||
$this->assertSame($expected, $event->getAuthor(), 'Author name not set correctly');
|
||||
|
|
@ -258,7 +260,7 @@ class ManagerTest extends TestCase {
|
|||
->getMock();
|
||||
$consumer->expects($this->once())
|
||||
->method('receive')
|
||||
->willReturnCallback(function (\OCP\Activity\IEvent $event) {
|
||||
->willReturnCallback(function (IEvent $event): void {
|
||||
$this->assertSame('test_app', $event->getApp(), 'App not set correctly');
|
||||
$this->assertSame('test_type', $event->getType(), 'Type not set correctly');
|
||||
$this->assertSame('test_affected', $event->getAffectedUser(), 'Affected user not set correctly');
|
||||
|
|
@ -281,7 +283,7 @@ class ManagerTest extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
class NoOpConsumer implements \OCP\Activity\IConsumer {
|
||||
public function receive(\OCP\Activity\IEvent $event) {
|
||||
class NoOpConsumer implements IConsumer {
|
||||
public function receive(IEvent $event) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ namespace Test;
|
|||
*
|
||||
* @package Test
|
||||
*/
|
||||
|
||||
use OC\AllConfig;
|
||||
use OC\SystemConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\PreConditionNotMetException;
|
||||
use OCP\Server;
|
||||
|
||||
class AllConfigTest extends \Test\TestCase {
|
||||
/** @var \OCP\IDBConnection */
|
||||
|
|
@ -24,7 +26,7 @@ class AllConfigTest extends \Test\TestCase {
|
|||
|
||||
protected function getConfig($systemConfig = null, $connection = null) {
|
||||
if ($this->connection === null) {
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
}
|
||||
if ($connection === null) {
|
||||
$connection = $this->connection;
|
||||
|
|
@ -34,7 +36,7 @@ class AllConfigTest extends \Test\TestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
}
|
||||
return new \OC\AllConfig($systemConfig, $connection);
|
||||
return new AllConfig($systemConfig, $connection);
|
||||
}
|
||||
|
||||
public function testDeleteUserValue(): void {
|
||||
|
|
@ -147,7 +149,7 @@ class AllConfigTest extends \Test\TestCase {
|
|||
|
||||
|
||||
public function testSetUserValueWithPreConditionFailure(): void {
|
||||
$this->expectException(\OCP\PreConditionNotMetException::class);
|
||||
$this->expectException(PreConditionNotMetException::class);
|
||||
|
||||
$config = $this->getConfig();
|
||||
|
||||
|
|
@ -183,7 +185,7 @@ class AllConfigTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testSetUserValueWithPreConditionFailureWhenResultStillMatches(): void {
|
||||
$this->expectException(\OCP\PreConditionNotMetException::class);
|
||||
$this->expectException(PreConditionNotMetException::class);
|
||||
|
||||
$config = $this->getConfig();
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class AppManagerTest extends TestCase {
|
|||
});
|
||||
$config->expects($this->any())
|
||||
->method('setValue')
|
||||
->willReturnCallback(function ($app, $key, $value) use (&$appConfig) {
|
||||
->willReturnCallback(function ($app, $key, $value) use (&$appConfig): void {
|
||||
if (!isset($appConfig[$app])) {
|
||||
$appConfig[$app] = [];
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ class AppManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public static function dataGetAppIcon(): array {
|
||||
$nothing = function ($appId) {
|
||||
$nothing = function ($appId): void {
|
||||
self::assertEquals('test', $appId);
|
||||
throw new \RuntimeException();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
namespace Test\App;
|
||||
|
||||
use OC;
|
||||
use OC\App\PlatformRepository;
|
||||
|
||||
class PlatformRepositoryTest extends \Test\TestCase {
|
||||
/**
|
||||
|
|
@ -15,7 +15,7 @@ class PlatformRepositoryTest extends \Test\TestCase {
|
|||
* @param $input
|
||||
*/
|
||||
public function testVersion($input, $expected): void {
|
||||
$pr = new OC\App\PlatformRepository();
|
||||
$pr = new PlatformRepository();
|
||||
$normalizedVersion = $pr->normalizeVersion($input);
|
||||
$this->assertEquals($expected, $normalizedVersion);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use OCP\Exceptions\AppConfigUnknownKeyException;
|
|||
use OCP\IAppConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -87,9 +88,9 @@ class AppConfigTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OCP\Server::get(IDBConnection::class);
|
||||
$this->logger = \OCP\Server::get(LoggerInterface::class);
|
||||
$this->crypto = \OCP\Server::get(ICrypto::class);
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->logger = Server::get(LoggerInterface::class);
|
||||
$this->crypto = Server::get(ICrypto::class);
|
||||
|
||||
// storing current config and emptying the data table
|
||||
$sql = $this->connection->getQueryBuilder();
|
||||
|
|
@ -176,7 +177,7 @@ class AppConfigTest extends TestCase {
|
|||
*/
|
||||
private function generateAppConfig(bool $preLoading = true): IAppConfig {
|
||||
/** @var AppConfig $config */
|
||||
$config = new \OC\AppConfig(
|
||||
$config = new AppConfig(
|
||||
$this->connection,
|
||||
$this->logger,
|
||||
$this->crypto,
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@
|
|||
namespace Test\AppFramework;
|
||||
|
||||
use OC\AppFramework\App;
|
||||
use OC\AppFramework\DependencyInjection\DIContainer;
|
||||
use OC\AppFramework\Http\Dispatcher;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\IOutput;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
|
||||
function rrmdir($directory) {
|
||||
|
|
@ -43,10 +44,10 @@ class AppTest extends \Test\TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->container = new \OC\AppFramework\DependencyInjection\DIContainer('test', []);
|
||||
$this->container = new DIContainer('test', []);
|
||||
$this->controller = $this->createMock(Controller::class);
|
||||
$this->dispatcher = $this->createMock(Dispatcher::class);
|
||||
$this->io = $this->createMock(Http\IOutput::class);
|
||||
$this->io = $this->createMock(IOutput::class);
|
||||
|
||||
$this->headers = ['key' => 'value'];
|
||||
$this->output = 'hi';
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace lib\AppFramework\Bootstrap;
|
|||
|
||||
use OC\AppFramework\Bootstrap\Coordinator;
|
||||
use OC\Support\CrashReport\Registry;
|
||||
use OCA\Settings\AppInfo\Application;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
|
|
@ -76,7 +77,7 @@ class CoordinatorTest extends TestCase {
|
|||
$appId = 'settings';
|
||||
$this->serverContainer->expects($this->once())
|
||||
->method('query')
|
||||
->with(\OCA\Settings\AppInfo\Application::class)
|
||||
->with(Application::class)
|
||||
->willThrowException(new QueryException(''));
|
||||
$this->logger->expects($this->once())
|
||||
->method('error');
|
||||
|
|
@ -86,10 +87,10 @@ class CoordinatorTest extends TestCase {
|
|||
|
||||
public function testBootAppNotBootable(): void {
|
||||
$appId = 'settings';
|
||||
$mockApp = $this->createMock(\OCA\Settings\AppInfo\Application::class);
|
||||
$mockApp = $this->createMock(Application::class);
|
||||
$this->serverContainer->expects($this->once())
|
||||
->method('query')
|
||||
->with(\OCA\Settings\AppInfo\Application::class)
|
||||
->with(Application::class)
|
||||
->willReturn($mockApp);
|
||||
|
||||
$this->coordinator->bootApp($appId);
|
||||
|
|
@ -110,7 +111,7 @@ class CoordinatorTest extends TestCase {
|
|||
};
|
||||
$this->serverContainer->expects($this->once())
|
||||
->method('query')
|
||||
->with(\OCA\Settings\AppInfo\Application::class)
|
||||
->with(Application::class)
|
||||
->willReturn($mockApp);
|
||||
|
||||
$this->coordinator->bootApp($appId);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace lib\AppFramework\Bootstrap;
|
|||
|
||||
use OC\AppFramework\Bootstrap\FunctionInjector;
|
||||
use OC\AppFramework\Utility\SimpleContainer;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use Test\TestCase;
|
||||
|
||||
interface Foo {
|
||||
|
|
@ -27,7 +28,7 @@ class FunctionInjectorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testInjectFnNotRegistered(): void {
|
||||
$this->expectException(\OCP\AppFramework\QueryException::class);
|
||||
$this->expectException(QueryException::class);
|
||||
|
||||
(new FunctionInjector($this->container))->injectFn(static function (Foo $p1): void {
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,17 +11,14 @@ use OCP\IRequest;
|
|||
use OCP\ISession;
|
||||
|
||||
class TestController extends PublicShareController {
|
||||
/** @var string */
|
||||
private $hash;
|
||||
|
||||
/** @var bool */
|
||||
private $isProtected;
|
||||
|
||||
public function __construct(string $appName, IRequest $request, ISession $session, string $hash, bool $isProtected) {
|
||||
public function __construct(
|
||||
string $appName,
|
||||
IRequest $request,
|
||||
ISession $session,
|
||||
private string $hash,
|
||||
private bool $isProtected,
|
||||
) {
|
||||
parent::__construct($appName, $request, $session);
|
||||
|
||||
$this->hash = $hash;
|
||||
$this->isProtected = $isProtected;
|
||||
}
|
||||
|
||||
protected function getPasswordHash(): string {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ use PHPUnit\Framework\Constraint\IsType;
|
|||
* @method void setDatetime(\DateTimeImmutable $datetime)
|
||||
*/
|
||||
class TestEntity extends Entity {
|
||||
protected $name;
|
||||
protected $email;
|
||||
protected $testId;
|
||||
protected $smallInt;
|
||||
|
|
@ -49,7 +48,9 @@ class TestEntity extends Entity {
|
|||
protected $time;
|
||||
protected $datetime;
|
||||
|
||||
public function __construct($name = null) {
|
||||
public function __construct(
|
||||
protected $name = null,
|
||||
) {
|
||||
$this->addType('testId', Types::INTEGER);
|
||||
$this->addType('smallInt', Types::SMALLINT);
|
||||
$this->addType('bigInt', Types::BIGINT);
|
||||
|
|
@ -63,8 +64,6 @@ class TestEntity extends Entity {
|
|||
$this->addType('trueOrFalse', 'bool');
|
||||
$this->addType('legacyInt', 'int');
|
||||
$this->addType('doubleNowFloat', 'double');
|
||||
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function setAnotherBool(bool $anotherBool): void {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class QBMapperDBTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OCP\Server::get(IDBConnection::class);
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->prepareTestingTable();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class QBMapperTest extends \Test\TestCase {
|
|||
];
|
||||
$this->qb->expects($this->exactly(6))
|
||||
->method('createNamedParameter')
|
||||
->willReturnCallback(function () use (&$createNamedParameterCalls) {
|
||||
->willReturnCallback(function () use (&$createNamedParameterCalls): void {
|
||||
$expected = array_shift($createNamedParameterCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -142,7 +142,7 @@ class QBMapperTest extends \Test\TestCase {
|
|||
];
|
||||
$this->qb->expects($this->exactly(6))
|
||||
->method('setValue')
|
||||
->willReturnCallback(function () use (&$setValueCalls) {
|
||||
->willReturnCallback(function () use (&$setValueCalls): void {
|
||||
$expected = array_shift($setValueCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -184,7 +184,7 @@ class QBMapperTest extends \Test\TestCase {
|
|||
];
|
||||
$this->qb->expects($this->exactly(8))
|
||||
->method('createNamedParameter')
|
||||
->willReturnCallback(function () use (&$createNamedParameterCalls) {
|
||||
->willReturnCallback(function () use (&$createNamedParameterCalls): void {
|
||||
$expected = array_shift($createNamedParameterCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -200,7 +200,7 @@ class QBMapperTest extends \Test\TestCase {
|
|||
];
|
||||
$this->qb->expects($this->exactly(7))
|
||||
->method('set')
|
||||
->willReturnCallback(function () use (&$setCalls) {
|
||||
->willReturnCallback(function () use (&$setCalls): void {
|
||||
$expected = array_shift($setCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class TransactionalTest extends TestCase {
|
|||
}
|
||||
|
||||
public function fail(): void {
|
||||
$this->atomic(function () {
|
||||
$this->atomic(function (): void {
|
||||
throw new RuntimeException('nope');
|
||||
}, $this->db);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,16 +21,14 @@ class ClassA2 implements Interface1 {
|
|||
}
|
||||
|
||||
class ClassB {
|
||||
/** @var Interface1 */
|
||||
public $interface1;
|
||||
|
||||
/**
|
||||
* ClassB constructor.
|
||||
*
|
||||
* @param Interface1 $interface1
|
||||
*/
|
||||
public function __construct(Interface1 $interface1) {
|
||||
$this->interface1 = $interface1;
|
||||
public function __construct(
|
||||
public Interface1 $interface1,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace Test\AppFramework\Http;
|
|||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\IRequest;
|
||||
use OCP\Server;
|
||||
|
||||
class DataResponseTest extends \Test\TestCase {
|
||||
/**
|
||||
|
|
@ -53,7 +54,7 @@ class DataResponseTest extends \Test\TestCase {
|
|||
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self';frame-ancestors 'none'",
|
||||
'Feature-Policy' => "autoplay 'none';camera 'none';fullscreen 'none';geolocation 'none';microphone 'none';payment 'none'",
|
||||
'X-Robots-Tag' => 'noindex, nofollow',
|
||||
'X-Request-Id' => \OC::$server->get(IRequest::class)->getId(),
|
||||
'X-Request-Id' => Server::get(IRequest::class)->getId(),
|
||||
];
|
||||
$expectedHeaders = array_merge($expectedHeaders, $headers);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use OCP\IConfig;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\IRequest;
|
||||
use OCP\IRequestId;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -130,7 +131,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OCP\Server::get(IDBConnection::class),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container,
|
||||
|
|
@ -307,7 +308,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->http, $this->middlewareDispatcher, $this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container
|
||||
|
|
@ -340,7 +341,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->http, $this->middlewareDispatcher, $this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container
|
||||
|
|
@ -376,7 +377,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->http, $this->middlewareDispatcher, $this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container
|
||||
|
|
@ -411,7 +412,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->http, $this->middlewareDispatcher, $this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container
|
||||
|
|
@ -447,7 +448,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->http, $this->middlewareDispatcher, $this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container
|
||||
|
|
@ -482,7 +483,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->http, $this->middlewareDispatcher, $this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container
|
||||
|
|
@ -520,7 +521,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->http, $this->middlewareDispatcher, $this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container
|
||||
|
|
@ -564,7 +565,7 @@ class DispatcherTest extends \Test\TestCase {
|
|||
$this->reflector,
|
||||
$this->request,
|
||||
$this->config,
|
||||
\OC::$server->getDatabaseConnection(),
|
||||
Server::get(IDBConnection::class),
|
||||
$this->logger,
|
||||
$this->eventLogger,
|
||||
$this->container,
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
namespace Test\AppFramework\Http;
|
||||
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Template\PublicTemplateResponse;
|
||||
use OCP\AppFramework\Http\Template\SimpleMenuAction;
|
||||
use Test\TestCase;
|
||||
|
||||
class PublicTemplateResponseTest extends TestCase {
|
||||
|
|
@ -28,7 +28,7 @@ class PublicTemplateResponseTest extends TestCase {
|
|||
|
||||
public function testActionSingle(): void {
|
||||
$actions = [
|
||||
new Http\Template\SimpleMenuAction('link', 'Download', 'download', 'downloadLink', 0)
|
||||
new SimpleMenuAction('link', 'Download', 'download', 'downloadLink', 0)
|
||||
];
|
||||
$template = new PublicTemplateResponse('app', 'home', ['key' => 'value']);
|
||||
$template->setHeaderActions($actions);
|
||||
|
|
@ -41,9 +41,9 @@ class PublicTemplateResponseTest extends TestCase {
|
|||
|
||||
public function testActionMultiple(): void {
|
||||
$actions = [
|
||||
new Http\Template\SimpleMenuAction('link1', 'Download1', 'download1', 'downloadLink1', 100),
|
||||
new Http\Template\SimpleMenuAction('link2', 'Download2', 'download2', 'downloadLink2', 20),
|
||||
new Http\Template\SimpleMenuAction('link3', 'Download3', 'download3', 'downloadLink3', 0)
|
||||
new SimpleMenuAction('link1', 'Download1', 'download1', 'downloadLink1', 100),
|
||||
new SimpleMenuAction('link2', 'Download2', 'download2', 'downloadLink2', 20),
|
||||
new SimpleMenuAction('link3', 'Download3', 'download3', 'downloadLink3', 0)
|
||||
];
|
||||
$template = new PublicTemplateResponse('app', 'home', ['key' => 'value']);
|
||||
$template->setHeaderActions($actions);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
namespace Test\AppFramework\Http;
|
||||
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\ContentSecurityPolicy;
|
||||
use OCP\AppFramework\Http\EmptyContentSecurityPolicy;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
|
||||
|
|
@ -54,7 +56,7 @@ class ResponseTest extends \Test\TestCase {
|
|||
$expected = [
|
||||
'Content-Security-Policy' => "default-src 'none';base-uri 'none';manifest-src 'self';script-src 'self' 'unsafe-inline';style-src 'self' 'unsafe-inline';img-src 'self';font-src 'self' data:;connect-src 'self';media-src 'self'",
|
||||
];
|
||||
$policy = new Http\ContentSecurityPolicy();
|
||||
$policy = new ContentSecurityPolicy();
|
||||
|
||||
$this->childResponse->setContentSecurityPolicy($policy);
|
||||
$headers = $this->childResponse->getHeaders();
|
||||
|
|
@ -63,14 +65,14 @@ class ResponseTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testGetCsp(): void {
|
||||
$policy = new Http\ContentSecurityPolicy();
|
||||
$policy = new ContentSecurityPolicy();
|
||||
|
||||
$this->childResponse->setContentSecurityPolicy($policy);
|
||||
$this->assertEquals($policy, $this->childResponse->getContentSecurityPolicy());
|
||||
}
|
||||
|
||||
public function testGetCspEmpty(): void {
|
||||
$this->assertEquals(new Http\EmptyContentSecurityPolicy(), $this->childResponse->getContentSecurityPolicy());
|
||||
$this->assertEquals(new EmptyContentSecurityPolicy(), $this->childResponse->getContentSecurityPolicy());
|
||||
}
|
||||
|
||||
public function testAddHeaderValueNullDeletesIt(): void {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
|
|||
->method($this->anything());
|
||||
$this->dispatcher->expects($this->once())
|
||||
->method('dispatchTyped')
|
||||
->willReturnCallback(function ($event) {
|
||||
->willReturnCallback(function ($event): void {
|
||||
if ($event instanceof BeforeTemplateRenderedEvent && $event->isLoggedIn() === false) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
|
|||
->willReturn(false);
|
||||
$this->dispatcher->expects($this->once())
|
||||
->method('dispatchTyped')
|
||||
->willReturnCallback(function ($event) {
|
||||
->willReturnCallback(function ($event): void {
|
||||
if ($event instanceof BeforeTemplateRenderedEvent && $event->isLoggedIn() === false) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ class AdditionalScriptsMiddlewareTest extends \Test\TestCase {
|
|||
->willReturn(true);
|
||||
$this->dispatcher->expects($this->once())
|
||||
->method('dispatchTyped')
|
||||
->willReturnCallback(function ($event) {
|
||||
->willReturnCallback(function ($event): void {
|
||||
if ($event instanceof BeforeTemplateRenderedEvent && $event->isLoggedIn() === true) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,17 +34,16 @@ class TestMiddleware extends Middleware {
|
|||
public $response;
|
||||
public $output;
|
||||
|
||||
private $beforeControllerThrowsEx;
|
||||
|
||||
/**
|
||||
* @param boolean $beforeControllerThrowsEx
|
||||
*/
|
||||
public function __construct($beforeControllerThrowsEx) {
|
||||
public function __construct(
|
||||
private $beforeControllerThrowsEx,
|
||||
) {
|
||||
self::$beforeControllerCalled = 0;
|
||||
self::$afterControllerCalled = 0;
|
||||
self::$afterExceptionCalled = 0;
|
||||
self::$beforeOutputCalled = 0;
|
||||
$this->beforeControllerThrowsEx = $beforeControllerThrowsEx;
|
||||
}
|
||||
|
||||
public function beforeController($controller, $methodName) {
|
||||
|
|
@ -136,13 +135,13 @@ class MiddlewareDispatcherTest extends \Test\TestCase {
|
|||
|
||||
public function testAfterExceptionShouldReturnResponseOfMiddleware(): void {
|
||||
$response = new Response();
|
||||
$m1 = $this->getMockBuilder(\OCP\AppFramework\Middleware::class)
|
||||
$m1 = $this->getMockBuilder(Middleware::class)
|
||||
->onlyMethods(['afterException', 'beforeController'])
|
||||
->getMock();
|
||||
$m1->expects($this->never())
|
||||
->method('afterException');
|
||||
|
||||
$m2 = $this->getMockBuilder(\OCP\AppFramework\Middleware::class)
|
||||
$m2 = $this->getMockBuilder(Middleware::class)
|
||||
->onlyMethods(['afterException', 'beforeController'])
|
||||
->getMock();
|
||||
$m2->expects($this->once())
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace Test\AppFramework\Middleware;
|
|||
use OC\AppFramework\Middleware\NotModifiedMiddleware;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\IRequest;
|
||||
|
||||
class NotModifiedMiddlewareTest extends \Test\TestCase {
|
||||
|
|
@ -68,7 +69,7 @@ class NotModifiedMiddlewareTest extends \Test\TestCase {
|
|||
return '';
|
||||
});
|
||||
|
||||
$response = new Http\Response();
|
||||
$response = new Response();
|
||||
if ($etag !== null) {
|
||||
$response->setETag($etag);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use OC\AppFramework\OCS\V1Response;
|
|||
use OC\AppFramework\OCS\V2Response;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
use OCP\AppFramework\OCS\OCSBadRequestException;
|
||||
use OCP\AppFramework\OCS\OCSException;
|
||||
|
|
@ -82,7 +83,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
|
|||
$this->assertSame($message, $this->invokePrivate($result, 'statusMessage'));
|
||||
|
||||
if ($exception->getCode() === 0) {
|
||||
$this->assertSame(\OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR, $result->getOCSStatus());
|
||||
$this->assertSame(OCSController::RESPOND_UNKNOWN_ERROR, $result->getOCSStatus());
|
||||
} else {
|
||||
$this->assertSame($code, $result->getOCSStatus());
|
||||
}
|
||||
|
|
@ -112,7 +113,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
|
|||
|
||||
$this->assertSame($message, $this->invokePrivate($result, 'statusMessage'));
|
||||
if ($exception->getCode() === 0) {
|
||||
$this->assertSame(\OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR, $result->getOCSStatus());
|
||||
$this->assertSame(OCSController::RESPOND_UNKNOWN_ERROR, $result->getOCSStatus());
|
||||
} else {
|
||||
$this->assertSame($code, $result->getOCSStatus());
|
||||
}
|
||||
|
|
@ -141,7 +142,7 @@ class OCSMiddlewareTest extends \Test\TestCase {
|
|||
|
||||
$this->assertSame($message, $this->invokePrivate($result, 'statusMessage'));
|
||||
if ($exception->getCode() === 0) {
|
||||
$this->assertSame(\OCP\AppFramework\OCSController::RESPOND_UNKNOWN_ERROR, $result->getOCSStatus());
|
||||
$this->assertSame(OCSController::RESPOND_UNKNOWN_ERROR, $result->getOCSStatus());
|
||||
} else {
|
||||
$this->assertSame($code, $result->getOCSStatus());
|
||||
}
|
||||
|
|
@ -151,16 +152,16 @@ class OCSMiddlewareTest extends \Test\TestCase {
|
|||
public static function dataAfterController(): array {
|
||||
return [
|
||||
[OCSController::class, new Response(), false],
|
||||
[OCSController::class, new Http\JSONResponse(), false],
|
||||
[OCSController::class, new Http\JSONResponse(['message' => 'foo']), false],
|
||||
[OCSController::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), true, OCSController::RESPOND_UNAUTHORISED],
|
||||
[OCSController::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), true],
|
||||
[OCSController::class, new JSONResponse(), false],
|
||||
[OCSController::class, new JSONResponse(['message' => 'foo']), false],
|
||||
[OCSController::class, new JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), true, OCSController::RESPOND_UNAUTHORISED],
|
||||
[OCSController::class, new JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), true],
|
||||
|
||||
[Controller::class, new Response(), false],
|
||||
[Controller::class, new Http\JSONResponse(), false],
|
||||
[Controller::class, new Http\JSONResponse(['message' => 'foo']), false],
|
||||
[Controller::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), false],
|
||||
[Controller::class, new Http\JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), false],
|
||||
[Controller::class, new JSONResponse(), false],
|
||||
[Controller::class, new JSONResponse(['message' => 'foo']), false],
|
||||
[Controller::class, new JSONResponse(['message' => 'foo'], Http::STATUS_UNAUTHORIZED), false],
|
||||
[Controller::class, new JSONResponse(['message' => 'foo'], Http::STATUS_FORBIDDEN), false],
|
||||
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ class BruteForceMiddlewareTest extends TestCase {
|
|||
$this->throttler
|
||||
->expects($this->exactly(2))
|
||||
->method('registerAttempt')
|
||||
->willReturnCallback(function () use (&$attemptCalls) {
|
||||
->willReturnCallback(function () use (&$attemptCalls): void {
|
||||
$expected = array_shift($attemptCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use OC\AppFramework\Http\Request;
|
|||
use OC\AppFramework\Middleware\Security\CORSMiddleware;
|
||||
use OC\AppFramework\Middleware\Security\Exceptions\SecurityException;
|
||||
use OC\AppFramework\Utility\ControllerMethodReflector;
|
||||
use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
|
||||
use OC\User\Session;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\Response;
|
||||
|
|
@ -124,7 +125,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
|
|||
* @dataProvider dataCorsIgnoredIfWithCredentialsHeaderPresent
|
||||
*/
|
||||
public function testCorsIgnoredIfWithCredentialsHeaderPresent(string $method): void {
|
||||
$this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class);
|
||||
$this->expectException(SecurityException::class);
|
||||
|
||||
$request = new Request(
|
||||
[
|
||||
|
|
@ -253,7 +254,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
|
|||
* @dataProvider dataCORSShouldFailIfPasswordLoginIsForbidden
|
||||
*/
|
||||
public function testCORSShouldFailIfPasswordLoginIsForbidden(string $method): void {
|
||||
$this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class);
|
||||
$this->expectException(SecurityException::class);
|
||||
|
||||
$request = new Request(
|
||||
['server' => [
|
||||
|
|
@ -268,7 +269,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
|
|||
$this->session->expects($this->once())
|
||||
->method('logClientIn')
|
||||
->with($this->equalTo('user'), $this->equalTo('pass'))
|
||||
->will($this->throwException(new \OC\Authentication\Exceptions\PasswordLoginForbiddenException));
|
||||
->will($this->throwException(new PasswordLoginForbiddenException));
|
||||
$this->reflector->reflect($this->controller, $method);
|
||||
$middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler, $this->logger);
|
||||
|
||||
|
|
@ -286,7 +287,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
|
|||
* @dataProvider dataCORSShouldNotAllowCookieAuth
|
||||
*/
|
||||
public function testCORSShouldNotAllowCookieAuth(string $method): void {
|
||||
$this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\SecurityException::class);
|
||||
$this->expectException(SecurityException::class);
|
||||
|
||||
$request = new Request(
|
||||
['server' => [
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ declare(strict_types=1);
|
|||
|
||||
namespace Test\AppFramework\Middleware\Security\Mock;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\Attribute\CORS;
|
||||
use OCP\AppFramework\Http\Attribute\PublicPage;
|
||||
|
||||
class CORSMiddlewareController extends \OCP\AppFramework\Controller {
|
||||
class CORSMiddlewareController extends Controller {
|
||||
/**
|
||||
* @CORS
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Test\AppFramework\Middleware\Security\Mock;
|
||||
|
||||
class NormalController extends \OCP\AppFramework\Controller {
|
||||
use OCP\AppFramework\Controller;
|
||||
|
||||
class NormalController extends Controller {
|
||||
public function foo() {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace Test\AppFramework\Middleware\Security\Mock;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
|
||||
|
||||
class PasswordConfirmationMiddlewareController extends \OCP\AppFramework\Controller {
|
||||
class PasswordConfirmationMiddlewareController extends Controller {
|
||||
public function testNoAnnotationNorAttribute() {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Test\AppFramework\Middleware\Security\Mock;
|
||||
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\AppFramework\Http\Attribute\ExAppRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
||||
|
|
@ -16,7 +17,7 @@ use OCP\AppFramework\Http\Attribute\PublicPage;
|
|||
use OCP\AppFramework\Http\Attribute\StrictCookiesRequired;
|
||||
use OCP\AppFramework\Http\Attribute\SubAdminRequired;
|
||||
|
||||
class SecurityMiddlewareController extends \OCP\AppFramework\Controller {
|
||||
class SecurityMiddlewareController extends Controller {
|
||||
/**
|
||||
* @PublicPage
|
||||
* @NoCSRFRequired
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
|
|||
* @dataProvider dataPublicPage
|
||||
*/
|
||||
public function testCsrfCheck(string $method): void {
|
||||
$this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class);
|
||||
$this->expectException(CrossSiteRequestForgeryException::class);
|
||||
|
||||
$this->request->expects($this->once())
|
||||
->method('passesCSRFCheck')
|
||||
|
|
@ -375,7 +375,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
|
|||
* @dataProvider dataPublicPage
|
||||
*/
|
||||
public function testFailCsrfCheck(string $method): void {
|
||||
$this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\CrossSiteRequestForgeryException::class);
|
||||
$this->expectException(CrossSiteRequestForgeryException::class);
|
||||
|
||||
$this->request->expects($this->once())
|
||||
->method('passesCSRFCheck')
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ namespace Test\AppFramework\OCS;
|
|||
use OC\AppFramework\OCS\BaseResponse;
|
||||
|
||||
class ArrayValue implements \JsonSerializable {
|
||||
private $array;
|
||||
public function __construct(array $array) {
|
||||
$this->array = $array;
|
||||
public function __construct(
|
||||
private array $array,
|
||||
) {
|
||||
}
|
||||
|
||||
public function jsonSerialize(): mixed {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||
namespace Test\AppFramework\Utility;
|
||||
|
||||
use OC\AppFramework\Utility\SimpleContainer;
|
||||
use OCP\AppFramework\QueryException;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
interface TestInterface {
|
||||
|
|
@ -20,42 +21,40 @@ class ClassEmptyConstructor implements IInterfaceConstructor {
|
|||
}
|
||||
|
||||
class ClassSimpleConstructor implements IInterfaceConstructor {
|
||||
public $test;
|
||||
public function __construct($test) {
|
||||
$this->test = $test;
|
||||
public function __construct(
|
||||
public $test,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
class ClassComplexConstructor {
|
||||
public $class;
|
||||
public $test;
|
||||
public function __construct(ClassSimpleConstructor $class, $test) {
|
||||
$this->class = $class;
|
||||
$this->test = $test;
|
||||
public function __construct(
|
||||
public ClassSimpleConstructor $class,
|
||||
public $test,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
class ClassNullableUntypedConstructorArg {
|
||||
public $class;
|
||||
public function __construct($class) {
|
||||
$this->class = $class;
|
||||
public function __construct(
|
||||
public $class,
|
||||
) {
|
||||
}
|
||||
}
|
||||
class ClassNullableTypedConstructorArg {
|
||||
public $class;
|
||||
public function __construct(?\Some\Class $class) {
|
||||
$this->class = $class;
|
||||
public function __construct(
|
||||
public ?\Some\Class $class,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
interface IInterfaceConstructor {
|
||||
}
|
||||
class ClassInterfaceConstructor {
|
||||
public $class;
|
||||
public $test;
|
||||
public function __construct(IInterfaceConstructor $class, $test) {
|
||||
$this->class = $class;
|
||||
$this->test = $test;
|
||||
public function __construct(
|
||||
public IInterfaceConstructor $class,
|
||||
public $test,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +82,7 @@ class SimpleContainerTest extends \Test\TestCase {
|
|||
$this->container->query('something really hard', false);
|
||||
$this->fail('Expected `QueryException` exception was not thrown');
|
||||
} catch (\Throwable $exception) {
|
||||
$this->assertInstanceOf(\OCP\AppFramework\QueryException::class, $exception);
|
||||
$this->assertInstanceOf(QueryException::class, $exception);
|
||||
$this->assertInstanceOf(NotFoundExceptionInterface::class, $exception);
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +96,7 @@ class SimpleContainerTest extends \Test\TestCase {
|
|||
$this->container->query('something really hard');
|
||||
$this->fail('Expected `QueryException` exception was not thrown');
|
||||
} catch (\Throwable $exception) {
|
||||
$this->assertInstanceOf(\OCP\AppFramework\QueryException::class, $exception);
|
||||
$this->assertInstanceOf(QueryException::class, $exception);
|
||||
$this->assertInstanceOf(NotFoundExceptionInterface::class, $exception);
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +104,7 @@ class SimpleContainerTest extends \Test\TestCase {
|
|||
|
||||
|
||||
public function testNotAClass(): void {
|
||||
$this->expectException(\OCP\AppFramework\QueryException::class);
|
||||
$this->expectException(QueryException::class);
|
||||
|
||||
$this->container->query('Test\AppFramework\Utility\TestInterface');
|
||||
}
|
||||
|
|
@ -214,7 +213,7 @@ class SimpleContainerTest extends \Test\TestCase {
|
|||
|
||||
|
||||
public function testConstructorComplexNoTestParameterFound(): void {
|
||||
$this->expectException(\OCP\AppFramework\QueryException::class);
|
||||
$this->expectException(QueryException::class);
|
||||
|
||||
$object = $this->container->query(
|
||||
'Test\AppFramework\Utility\ClassComplexConstructor'
|
||||
|
|
@ -245,7 +244,7 @@ class SimpleContainerTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testQueryUntypedNullable(): void {
|
||||
$this->expectException(\OCP\AppFramework\QueryException::class);
|
||||
$this->expectException(QueryException::class);
|
||||
|
||||
$object = $this->container->query(
|
||||
ClassNullableUntypedConstructorArg::class
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use OCP\IDBConnection;
|
|||
use OCP\IGroupManager;
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Server;
|
||||
use OCP\ServerVersion;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
|
@ -469,8 +470,8 @@ class AppTest extends \Test\TestCase {
|
|||
* @dataProvider appConfigValuesProvider
|
||||
*/
|
||||
public function testEnabledApps($user, $expectedApps, $forceAll): void {
|
||||
$userManager = \OCP\Server::get(IUserManager::class);
|
||||
$groupManager = \OCP\Server::get(IGroupManager::class);
|
||||
$userManager = Server::get(IUserManager::class);
|
||||
$groupManager = Server::get(IGroupManager::class);
|
||||
$user1 = $userManager->createUser(self::TEST_USER1, 'NotAnEasyPassword123456+');
|
||||
$user2 = $userManager->createUser(self::TEST_USER2, 'NotAnEasyPassword123456_');
|
||||
$user3 = $userManager->createUser(self::TEST_USER3, 'NotAnEasyPassword123456?');
|
||||
|
|
@ -517,7 +518,7 @@ class AppTest extends \Test\TestCase {
|
|||
* enabled apps more than once when a user is set.
|
||||
*/
|
||||
public function testEnabledAppsCache(): void {
|
||||
$userManager = \OCP\Server::get(IUserManager::class);
|
||||
$userManager = Server::get(IUserManager::class);
|
||||
$user1 = $userManager->createUser(self::TEST_USER1, 'NotAnEasyPassword123456+');
|
||||
|
||||
\OC_User::setUserId(self::TEST_USER1);
|
||||
|
|
@ -549,7 +550,7 @@ class AppTest extends \Test\TestCase {
|
|||
/** @var AppConfig|MockObject */
|
||||
$appConfig = $this->getMockBuilder(AppConfig::class)
|
||||
->onlyMethods(['searchValues'])
|
||||
->setConstructorArgs([\OCP\Server::get(IDBConnection::class)])
|
||||
->setConstructorArgs([Server::get(IDBConnection::class)])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
|
|
@ -565,13 +566,13 @@ class AppTest extends \Test\TestCase {
|
|||
private function registerAppConfig(AppConfig $appConfig) {
|
||||
$this->overwriteService(AppConfig::class, $appConfig);
|
||||
$this->overwriteService(AppManager::class, new AppManager(
|
||||
\OCP\Server::get(IUserSession::class),
|
||||
\OCP\Server::get(IConfig::class),
|
||||
\OCP\Server::get(IGroupManager::class),
|
||||
\OCP\Server::get(ICacheFactory::class),
|
||||
\OCP\Server::get(IEventDispatcher::class),
|
||||
\OCP\Server::get(LoggerInterface::class),
|
||||
\OCP\Server::get(ServerVersion::class),
|
||||
Server::get(IUserSession::class),
|
||||
Server::get(IConfig::class),
|
||||
Server::get(IGroupManager::class),
|
||||
Server::get(ICacheFactory::class),
|
||||
Server::get(IEventDispatcher::class),
|
||||
Server::get(LoggerInterface::class),
|
||||
Server::get(ServerVersion::class),
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
namespace Test\Archive;
|
||||
|
||||
use OC\Archive\TAR;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
|
||||
class TARTest extends TestBase {
|
||||
protected function getExisting() {
|
||||
|
|
@ -16,6 +18,6 @@ class TARTest extends TestBase {
|
|||
}
|
||||
|
||||
protected function getNew() {
|
||||
return new TAR(\OC::$server->getTempManager()->getTemporaryFile('.tar.gz'));
|
||||
return new TAR(Server::get(ITempManager::class)->getTemporaryFile('.tar.gz'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
|
||||
namespace Test\Archive;
|
||||
|
||||
use OCP\Files;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
|
||||
abstract class TestBase extends \Test\TestCase {
|
||||
/**
|
||||
* @var \OC\Archive\Archive
|
||||
|
|
@ -56,7 +60,7 @@ abstract class TestBase extends \Test\TestCase {
|
|||
$textFile = $dir . '/lorem.txt';
|
||||
$this->assertEquals(file_get_contents($textFile), $this->instance->getFile('lorem.txt'));
|
||||
|
||||
$tmpFile = \OC::$server->getTempManager()->getTemporaryFile('.txt');
|
||||
$tmpFile = Server::get(ITempManager::class)->getTemporaryFile('.txt');
|
||||
$this->instance->extractFile('lorem.txt', $tmpFile);
|
||||
$this->assertEquals(file_get_contents($textFile), file_get_contents($tmpFile));
|
||||
}
|
||||
|
|
@ -90,7 +94,7 @@ abstract class TestBase extends \Test\TestCase {
|
|||
$this->instance = $this->getNew();
|
||||
$fh = $this->instance->getStream('lorem.txt', 'w');
|
||||
$source = fopen($dir . '/lorem.txt', 'r');
|
||||
\OCP\Files::streamCopy($source, $fh);
|
||||
Files::streamCopy($source, $fh);
|
||||
fclose($source);
|
||||
fclose($fh);
|
||||
$this->assertTrue($this->instance->fileExists('lorem.txt'));
|
||||
|
|
@ -110,13 +114,13 @@ abstract class TestBase extends \Test\TestCase {
|
|||
public function testExtract(): void {
|
||||
$dir = \OC::$SERVERROOT . '/tests/data';
|
||||
$this->instance = $this->getExisting();
|
||||
$tmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$tmpDir = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
$this->instance->extract($tmpDir);
|
||||
$this->assertEquals(true, file_exists($tmpDir . 'lorem.txt'));
|
||||
$this->assertEquals(true, file_exists($tmpDir . 'dir/lorem.txt'));
|
||||
$this->assertEquals(true, file_exists($tmpDir . 'logo-wide.png'));
|
||||
$this->assertEquals(file_get_contents($dir . '/lorem.txt'), file_get_contents($tmpDir . 'lorem.txt'));
|
||||
\OCP\Files::rmdirr($tmpDir);
|
||||
Files::rmdirr($tmpDir);
|
||||
}
|
||||
public function testMoveRemove(): void {
|
||||
$dir = \OC::$SERVERROOT . '/tests/data';
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
namespace Test\Archive;
|
||||
|
||||
use OC\Archive\ZIP;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
|
||||
class ZIPTest extends TestBase {
|
||||
protected function getExisting() {
|
||||
|
|
@ -16,7 +18,7 @@ class ZIPTest extends TestBase {
|
|||
}
|
||||
|
||||
protected function getNew() {
|
||||
$newZip = \OC::$server->getTempManager()->getTempBaseDir() . '/newArchive.zip';
|
||||
$newZip = Server::get(ITempManager::class)->getTempBaseDir() . '/newArchive.zip';
|
||||
if (file_exists($newZip)) {
|
||||
unlink($newZip);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class UserDeletedTokenCleanupListenerTest extends TestCase {
|
|||
];
|
||||
$this->manager->expects($this->exactly(3))
|
||||
->method('invalidateTokenById')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ class ManagerTest extends TestCase {
|
|||
$this->publicKeyTokenProvider
|
||||
->expects($this->exactly(2))
|
||||
->method('invalidateTokenById')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,13 +8,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Test\Authentication\Token;
|
||||
|
||||
use OC;
|
||||
use OC\Authentication\Token\PublicKeyToken;
|
||||
use OC\Authentication\Token\PublicKeyTokenMapper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\Authentication\Token\IToken;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\IUser;
|
||||
use OCP\Server;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -33,7 +34,7 @@ class PublicKeyTokenMapperTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->dbConnection = OC::$server->getDatabaseConnection();
|
||||
$this->dbConnection = Server::get(IDBConnection::class);
|
||||
$this->time = time();
|
||||
$this->resetDatabase();
|
||||
|
||||
|
|
@ -178,7 +179,7 @@ class PublicKeyTokenMapperTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetInvalidToken(): void {
|
||||
$this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
|
||||
$this->expectException(DoesNotExistException::class);
|
||||
|
||||
$token = 'thisisaninvalidtokenthatisnotinthedatabase';
|
||||
|
||||
|
|
@ -210,14 +211,14 @@ class PublicKeyTokenMapperTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetTokenByIdNotFound(): void {
|
||||
$this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
|
||||
$this->expectException(DoesNotExistException::class);
|
||||
|
||||
$this->mapper->getTokenById(-1);
|
||||
}
|
||||
|
||||
|
||||
public function testGetInvalidTokenById(): void {
|
||||
$this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class);
|
||||
$this->expectException(DoesNotExistException::class);
|
||||
|
||||
$id = '42';
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use OCP\IConfig;
|
|||
use OCP\IDBConnection;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Security\IHasher;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
|
@ -53,8 +54,8 @@ class PublicKeyTokenProviderTest extends TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->mapper = $this->createMock(PublicKeyTokenMapper::class);
|
||||
$this->hasher = \OC::$server->get(IHasher::class);
|
||||
$this->crypto = \OC::$server->getCrypto();
|
||||
$this->hasher = Server::get(IHasher::class);
|
||||
$this->crypto = Server::get(ICrypto::class);
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->config->method('getSystemValue')
|
||||
->willReturnMap([
|
||||
|
|
@ -232,7 +233,7 @@ class PublicKeyTokenProviderTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetPasswordPasswordLessToken(): void {
|
||||
$this->expectException(\OC\Authentication\Exceptions\PasswordlessTokenException::class);
|
||||
$this->expectException(PasswordlessTokenException::class);
|
||||
|
||||
$token = 'token1234';
|
||||
$tk = new PublicKeyToken();
|
||||
|
|
@ -243,7 +244,7 @@ class PublicKeyTokenProviderTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetPasswordInvalidToken(): void {
|
||||
$this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class);
|
||||
$this->expectException(InvalidTokenException::class);
|
||||
|
||||
$token = 'tokentokentokentokentoken';
|
||||
$uid = 'user';
|
||||
|
|
@ -294,7 +295,7 @@ class PublicKeyTokenProviderTest extends TestCase {
|
|||
|
||||
|
||||
public function testSetPasswordInvalidToken(): void {
|
||||
$this->expectException(\OC\Authentication\Exceptions\InvalidTokenException::class);
|
||||
$this->expectException(InvalidTokenException::class);
|
||||
|
||||
$token = $this->createMock(IToken::class);
|
||||
$tokenId = 'token123';
|
||||
|
|
@ -311,7 +312,7 @@ class PublicKeyTokenProviderTest extends TestCase {
|
|||
|
||||
$this->mapper->expects($this->exactly(2))
|
||||
->method('invalidate')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -350,7 +351,7 @@ class PublicKeyTokenProviderTest extends TestCase {
|
|||
];
|
||||
$this->mapper->expects($this->exactly(4))
|
||||
->method('invalidateOld')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -469,7 +470,7 @@ class PublicKeyTokenProviderTest extends TestCase {
|
|||
];
|
||||
$this->mapper->expects($this->exactly(2))
|
||||
->method('getToken')
|
||||
->willReturnCallback(function (string $token) use (&$calls) {
|
||||
->willReturnCallback(function (string $token) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals(hash('sha512', $expected), $token);
|
||||
throw new DoesNotExistException('nope');
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace Test\Authentication\TwoFactorAuth\Db;
|
||||
|
||||
use OC;
|
||||
use OC\Authentication\TwoFactorAuth\Db\ProviderUserAssignmentDao;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -27,7 +27,7 @@ class ProviderUserAssignmentDaoTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->dbConn = OC::$server->getDatabaseConnection();
|
||||
$this->dbConn = Server::get(IDBConnection::class);
|
||||
$qb = $this->dbConn->getQueryBuilder();
|
||||
$q = $qb->delete(ProviderUserAssignmentDao::TABLE_NAME);
|
||||
$q->execute();
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
namespace Test\Authentication\TwoFactorAuth;
|
||||
|
||||
use OC;
|
||||
use OC\Authentication\Exceptions\InvalidTokenException;
|
||||
use OC\Authentication\Token\IProvider as TokenProvider;
|
||||
use OC\Authentication\Token\IToken;
|
||||
use OC\Authentication\TwoFactorAuth\Manager;
|
||||
use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
|
||||
use OC\Authentication\TwoFactorAuth\ProviderLoader;
|
||||
|
|
@ -363,7 +364,7 @@ class ManagerTest extends TestCase {
|
|||
];
|
||||
$this->session->expects($this->exactly(2))
|
||||
->method('remove')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -404,7 +405,7 @@ class ManagerTest extends TestCase {
|
|||
'provider' => 'Fake 2FA',
|
||||
]))
|
||||
->willReturnSelf();
|
||||
$token = $this->createMock(OC\Authentication\Token\IToken::class);
|
||||
$token = $this->createMock(IToken::class);
|
||||
$this->tokenProvider->method('getToken')
|
||||
->with('mysessionid')
|
||||
->willReturn($token);
|
||||
|
|
@ -496,7 +497,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
$this->session->method('getId')
|
||||
->willReturn('mysessionid');
|
||||
$token = $this->createMock(OC\Authentication\Token\IToken::class);
|
||||
$token = $this->createMock(IToken::class);
|
||||
$this->tokenProvider->method('getToken')
|
||||
->with('mysessionid')
|
||||
->willReturn($token);
|
||||
|
|
@ -567,14 +568,14 @@ class ManagerTest extends TestCase {
|
|||
];
|
||||
$this->session->expects($this->exactly(2))
|
||||
->method('set')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
||||
$this->session->method('getId')
|
||||
->willReturn('mysessionid');
|
||||
$token = $this->createMock(OC\Authentication\Token\IToken::class);
|
||||
$token = $this->createMock(IToken::class);
|
||||
$this->tokenProvider->method('getToken')
|
||||
->with('mysessionid')
|
||||
->willReturn($token);
|
||||
|
|
@ -601,14 +602,14 @@ class ManagerTest extends TestCase {
|
|||
];
|
||||
$this->session->expects($this->exactly(2))
|
||||
->method('set')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
||||
$this->session->method('getId')
|
||||
->willReturn('mysessionid');
|
||||
$token = $this->createMock(OC\Authentication\Token\IToken::class);
|
||||
$token = $this->createMock(IToken::class);
|
||||
$this->tokenProvider->method('getToken')
|
||||
->with('mysessionid')
|
||||
->willReturn($token);
|
||||
|
|
@ -669,7 +670,7 @@ class ManagerTest extends TestCase {
|
|||
$this->session->method('getId')
|
||||
->willReturn('mysessionid');
|
||||
|
||||
$token = $this->createMock(OC\Authentication\Token\IToken::class);
|
||||
$token = $this->createMock(IToken::class);
|
||||
$token->method('getId')
|
||||
->willReturn(40);
|
||||
|
||||
|
|
@ -704,7 +705,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
$this->tokenProvider->method('getToken')
|
||||
->with('mysessionid')
|
||||
->willThrowException(new OC\Authentication\Exceptions\InvalidTokenException());
|
||||
->willThrowException(new InvalidTokenException());
|
||||
|
||||
$this->config->method('getUserKeys')->willReturn([]);
|
||||
|
||||
|
|
@ -736,7 +737,7 @@ class ManagerTest extends TestCase {
|
|||
];
|
||||
$this->config->expects($this->exactly(3))
|
||||
->method('deleteUserValue')
|
||||
->willReturnCallback(function () use (&$deleteUserValueCalls) {
|
||||
->willReturnCallback(function () use (&$deleteUserValueCalls): void {
|
||||
$expected = array_shift($deleteUserValueCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -748,7 +749,7 @@ class ManagerTest extends TestCase {
|
|||
];
|
||||
$this->tokenProvider->expects($this->exactly(3))
|
||||
->method('invalidateTokenById')
|
||||
->willReturnCallback(function () use (&$invalidateCalls) {
|
||||
->willReturnCallback(function () use (&$invalidateCalls): void {
|
||||
$expected = array_shift($invalidateCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -770,7 +771,7 @@ class ManagerTest extends TestCase {
|
|||
];
|
||||
$this->config->expects($this->exactly(3))
|
||||
->method('deleteUserValue')
|
||||
->willReturnCallback(function () use (&$deleteUserValueCalls) {
|
||||
->willReturnCallback(function () use (&$deleteUserValueCalls): void {
|
||||
$expected = array_shift($deleteUserValueCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
@ -782,7 +783,7 @@ class ManagerTest extends TestCase {
|
|||
];
|
||||
$this->tokenProvider->expects($this->exactly(3))
|
||||
->method('invalidateTokenById')
|
||||
->willReturnCallback(function ($user, $tokenId) use (&$invalidateCalls) {
|
||||
->willReturnCallback(function ($user, $tokenId) use (&$invalidateCalls): void {
|
||||
$expected = array_shift($invalidateCalls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
if ($tokenId === 43) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace lib\Authentication\TwoFactorAuth;
|
||||
|
||||
use OC\Authentication\Exceptions\InvalidProviderException;
|
||||
use OC\Authentication\TwoFactorAuth\ProviderLoader;
|
||||
use OC\Authentication\TwoFactorAuth\ProviderManager;
|
||||
use OCP\Authentication\TwoFactorAuth\IActivatableByAdmin;
|
||||
|
|
@ -43,7 +44,7 @@ class ProviderManagerTest extends TestCase {
|
|||
|
||||
|
||||
public function testTryEnableInvalidProvider(): void {
|
||||
$this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class);
|
||||
$this->expectException(InvalidProviderException::class);
|
||||
|
||||
$user = $this->createMock(IUser::class);
|
||||
$this->providerManager->tryEnableProviderFor('none', $user);
|
||||
|
|
@ -89,7 +90,7 @@ class ProviderManagerTest extends TestCase {
|
|||
|
||||
|
||||
public function testTryDisableInvalidProvider(): void {
|
||||
$this->expectException(\OC\Authentication\Exceptions\InvalidProviderException::class);
|
||||
$this->expectException(InvalidProviderException::class);
|
||||
|
||||
$user = $this->createMock(IUser::class);
|
||||
$this->providerManager->tryDisableProviderFor('none', $user);
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class RegistryTest extends TestCase {
|
|||
];
|
||||
$this->dispatcher->expects($this->exactly(2))
|
||||
->method('dispatchTyped')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
namespace Test\Avatar;
|
||||
|
||||
use OC\Avatar\UserAvatar;
|
||||
use OC\Files\SimpleFS\SimpleFolder;
|
||||
use OC\User\User;
|
||||
use OCP\Color;
|
||||
use OCP\Files\File;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\SimpleFS\ISimpleFile;
|
||||
|
|
@ -56,7 +58,7 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
->willReturn($file);
|
||||
|
||||
$this->folder->method('getFile')
|
||||
->willReturnCallback(function (string $path) {
|
||||
->willReturnCallback(function (string $path): void {
|
||||
if ($path === 'avatar.64.png') {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
|
@ -144,7 +146,7 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
if ($path === 'avatar.png') {
|
||||
return $file;
|
||||
} else {
|
||||
throw new \OCP\Files\NotFoundException;
|
||||
throw new NotFoundException;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -261,17 +263,17 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testMixPalette(): void {
|
||||
$colorFrom = new \OCP\Color(0, 0, 0);
|
||||
$colorTo = new \OCP\Color(6, 12, 18);
|
||||
$colorFrom = new Color(0, 0, 0);
|
||||
$colorTo = new Color(6, 12, 18);
|
||||
$steps = 6;
|
||||
$palette = \OCP\Color::mixPalette($steps, $colorFrom, $colorTo);
|
||||
$palette = Color::mixPalette($steps, $colorFrom, $colorTo);
|
||||
foreach ($palette as $j => $color) {
|
||||
// calc increment
|
||||
$incR = $colorTo->red() / $steps * $j;
|
||||
$incG = $colorTo->green() / $steps * $j;
|
||||
$incB = $colorTo->blue() / $steps * $j;
|
||||
// ensure everything is equal
|
||||
$this->assertEquals($color, new \OCP\Color($incR, $incG, $incB));
|
||||
$this->assertEquals($color, new Color($incR, $incG, $incB));
|
||||
}
|
||||
$hashToInt = $this->invokePrivate($this->avatar, 'hashToInt', ['abcdef', 18]);
|
||||
$this->assertTrue(gettype($hashToInt) === 'integer');
|
||||
|
|
@ -288,7 +290,7 @@ class UserAvatarTest extends \Test\TestCase {
|
|||
$l = $this->createMock(IL10N::class);
|
||||
$l->method('t')->willReturnArgument(0);
|
||||
|
||||
return new \OC\Avatar\UserAvatar(
|
||||
return new UserAvatar(
|
||||
$this->folder,
|
||||
$l,
|
||||
$user,
|
||||
|
|
|
|||
|
|
@ -7,14 +7,16 @@
|
|||
|
||||
namespace Test\BackgroundJob;
|
||||
|
||||
use OC\BackgroundJob\JobList;
|
||||
use OCP\BackgroundJob\IJob;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
* Class DummyJobList
|
||||
*
|
||||
* in memory job list for testing purposes
|
||||
*/
|
||||
class DummyJobList extends \OC\BackgroundJob\JobList {
|
||||
class DummyJobList extends JobList {
|
||||
/**
|
||||
* @var IJob[]
|
||||
*/
|
||||
|
|
@ -38,7 +40,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
|
|||
public function add($job, $argument = null, ?int $firstCheck = null): void {
|
||||
if (is_string($job)) {
|
||||
/** @var IJob $job */
|
||||
$job = \OCP\Server::get($job);
|
||||
$job = Server::get($job);
|
||||
}
|
||||
$job->setArgument($argument);
|
||||
$job->setId($this->lastId);
|
||||
|
|
|
|||
|
|
@ -10,10 +10,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Test\BackgroundJob;
|
||||
|
||||
use OC\BackgroundJob\JobList;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\IJob;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -40,15 +43,15 @@ class JobListTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->clearJobsList();
|
||||
$this->config = $this->createMock(IConfig::class);
|
||||
$this->timeFactory = $this->createMock(ITimeFactory::class);
|
||||
$this->instance = new \OC\BackgroundJob\JobList(
|
||||
$this->instance = new JobList(
|
||||
$this->connection,
|
||||
$this->config,
|
||||
$this->timeFactory,
|
||||
\OC::$server->get(LoggerInterface::class),
|
||||
Server::get(LoggerInterface::class),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -277,10 +280,10 @@ class JobListTest extends TestCase {
|
|||
->method('getTime')
|
||||
->willReturn(123456789);
|
||||
|
||||
$job = new TestJob($this->timeFactory, $this, function () {
|
||||
$job = new TestJob($this->timeFactory, $this, function (): void {
|
||||
});
|
||||
|
||||
$job2 = new TestJob($this->timeFactory, $this, function () {
|
||||
$job2 = new TestJob($this->timeFactory, $this, function (): void {
|
||||
});
|
||||
|
||||
$this->instance->add($job, 1);
|
||||
|
|
@ -310,10 +313,10 @@ class JobListTest extends TestCase {
|
|||
return time();
|
||||
});
|
||||
|
||||
$job = new TestParallelAwareJob($this->timeFactory, $this, function () {
|
||||
$job = new TestParallelAwareJob($this->timeFactory, $this, function (): void {
|
||||
});
|
||||
|
||||
$job2 = new TestParallelAwareJob($this->timeFactory, $this, function () {
|
||||
$job2 = new TestParallelAwareJob($this->timeFactory, $this, function (): void {
|
||||
});
|
||||
|
||||
$this->instance->add($job, 1);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
namespace Test\BackgroundJob;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class JobTest extends \Test\TestCase {
|
||||
|
|
@ -18,7 +19,7 @@ class JobTest extends \Test\TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->run = false;
|
||||
$this->timeFactory = \OCP\Server::get(ITimeFactory::class);
|
||||
$this->timeFactory = Server::get(ITimeFactory::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
\OC::$server->registerService(LoggerInterface::class, fn ($c) => $this->logger);
|
||||
|
|
@ -27,7 +28,7 @@ class JobTest extends \Test\TestCase {
|
|||
public function testRemoveAfterException(): void {
|
||||
$jobList = new DummyJobList();
|
||||
$e = new \Exception();
|
||||
$job = new TestJob($this->timeFactory, $this, function () use ($e) {
|
||||
$job = new TestJob($this->timeFactory, $this, function () use ($e): void {
|
||||
throw $e;
|
||||
});
|
||||
$jobList->add($job);
|
||||
|
|
@ -43,7 +44,7 @@ class JobTest extends \Test\TestCase {
|
|||
|
||||
public function testRemoveAfterError(): void {
|
||||
$jobList = new DummyJobList();
|
||||
$job = new TestJob($this->timeFactory, $this, function () {
|
||||
$job = new TestJob($this->timeFactory, $this, function (): void {
|
||||
$test = null;
|
||||
$test->someMethod();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace Test\BackgroundJob;
|
|||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\QueuedJob;
|
||||
use OCP\Server;
|
||||
|
||||
class TestQueuedJobNew extends QueuedJob {
|
||||
public bool $ran = false;
|
||||
|
|
@ -28,7 +29,7 @@ class QueuedJobTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testJobShouldBeRemovedNew(): void {
|
||||
$job = new TestQueuedJobNew(\OCP\Server::get(ITimeFactory::class));
|
||||
$job = new TestQueuedJobNew(Server::get(ITimeFactory::class));
|
||||
$job->setId(42);
|
||||
$this->jobList->add($job);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@
|
|||
namespace Test\BackgroundJob;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCP\Server;
|
||||
|
||||
class TestJob extends \OCP\BackgroundJob\Job {
|
||||
private $testCase;
|
||||
|
||||
class TestJob extends Job {
|
||||
/**
|
||||
* @var callable $callback
|
||||
*/
|
||||
|
|
@ -21,9 +21,12 @@ class TestJob extends \OCP\BackgroundJob\Job {
|
|||
* @param JobTest $testCase
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function __construct(?ITimeFactory $time = null, $testCase = null, $callback = null) {
|
||||
parent::__construct($time ?? \OCP\Server::get(ITimeFactory::class));
|
||||
$this->testCase = $testCase;
|
||||
public function __construct(
|
||||
?ITimeFactory $time = null,
|
||||
private $testCase = null,
|
||||
$callback = null,
|
||||
) {
|
||||
parent::__construct($time ?? Server::get(ITimeFactory::class));
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
namespace Test\BackgroundJob;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCP\Server;
|
||||
|
||||
class TestParallelAwareJob extends \OCP\BackgroundJob\Job {
|
||||
private $testCase;
|
||||
|
||||
class TestParallelAwareJob extends Job {
|
||||
/**
|
||||
* @var callable $callback
|
||||
*/
|
||||
|
|
@ -20,10 +20,13 @@ class TestParallelAwareJob extends \OCP\BackgroundJob\Job {
|
|||
* @param JobTest $testCase
|
||||
* @param callable $callback
|
||||
*/
|
||||
public function __construct(?ITimeFactory $time = null, $testCase = null, $callback = null) {
|
||||
parent::__construct($time ?? \OC::$server->get(ITimeFactory::class));
|
||||
public function __construct(
|
||||
?ITimeFactory $time = null,
|
||||
private $testCase = null,
|
||||
$callback = null,
|
||||
) {
|
||||
parent::__construct($time ?? Server::get(ITimeFactory::class));
|
||||
$this->setAllowParallelRuns(false);
|
||||
$this->testCase = $testCase;
|
||||
$this->callback = $callback;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
namespace Test\BackgroundJob;
|
||||
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Server;
|
||||
|
||||
class TimedJobTest extends \Test\TestCase {
|
||||
private DummyJobList $jobList;
|
||||
|
|
@ -17,7 +18,7 @@ class TimedJobTest extends \Test\TestCase {
|
|||
parent::setUp();
|
||||
|
||||
$this->jobList = new DummyJobList();
|
||||
$this->time = \OCP\Server::get(ITimeFactory::class);
|
||||
$this->time = Server::get(ITimeFactory::class);
|
||||
}
|
||||
|
||||
public function testShouldRunAfterIntervalNew(): void {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Test\Cache;
|
||||
|
||||
use OCP\Cache\CappedMemoryCache;
|
||||
|
||||
/**
|
||||
* Class CappedMemoryCacheTest
|
||||
*
|
||||
|
|
@ -15,11 +17,11 @@ namespace Test\Cache;
|
|||
class CappedMemoryCacheTest extends TestCache {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->instance = new \OCP\Cache\CappedMemoryCache();
|
||||
$this->instance = new CappedMemoryCache();
|
||||
}
|
||||
|
||||
public function testSetOverCap(): void {
|
||||
$instance = new \OCP\Cache\CappedMemoryCache(3);
|
||||
$instance = new CappedMemoryCache(3);
|
||||
|
||||
$instance->set('1', 'a');
|
||||
$instance->set('2', 'b');
|
||||
|
|
|
|||
|
|
@ -7,8 +7,16 @@
|
|||
|
||||
namespace Test\Cache;
|
||||
|
||||
use OC\Cache\File;
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\Storage\Local;
|
||||
use OC\Files\Storage\Temporary;
|
||||
use OC\Files\View;
|
||||
use OCP\Files\LockNotAcquiredException;
|
||||
use OCP\Files\Mount\IMountManager;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Lock\LockedException;
|
||||
use OCP\Server;
|
||||
use Test\Traits\UserTrait;
|
||||
|
||||
/**
|
||||
|
|
@ -55,17 +63,17 @@ class FileCacheTest extends TestCache {
|
|||
\OC_Hook::clear('OC_Filesystem');
|
||||
|
||||
/** @var IMountManager $manager */
|
||||
$manager = \OC::$server->get(IMountManager::class);
|
||||
$manager = Server::get(IMountManager::class);
|
||||
$manager->removeMount('/test');
|
||||
|
||||
$storage = new \OC\Files\Storage\Temporary([]);
|
||||
\OC\Files\Filesystem::mount($storage, [], '/test/cache');
|
||||
$storage = new Temporary([]);
|
||||
Filesystem::mount($storage, [], '/test/cache');
|
||||
|
||||
//set up the users dir
|
||||
$this->rootView = new \OC\Files\View('');
|
||||
$this->rootView = new View('');
|
||||
$this->rootView->mkdir('/test');
|
||||
|
||||
$this->instance = new \OC\Cache\File();
|
||||
$this->instance = new File();
|
||||
|
||||
// forces creation of cache folder for subsequent tests
|
||||
$this->instance->set('hack', 'hack');
|
||||
|
|
@ -89,10 +97,10 @@ class FileCacheTest extends TestCache {
|
|||
private function setupMockStorage() {
|
||||
$mockStorage = $this->getMockBuilder(Local::class)
|
||||
->onlyMethods(['filemtime', 'unlink'])
|
||||
->setConstructorArgs([['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]])
|
||||
->setConstructorArgs([['datadir' => Server::get(ITempManager::class)->getTemporaryFolder()]])
|
||||
->getMock();
|
||||
|
||||
\OC\Files\Filesystem::mount($mockStorage, [], '/test/cache');
|
||||
Filesystem::mount($mockStorage, [], '/test/cache');
|
||||
|
||||
return $mockStorage;
|
||||
}
|
||||
|
|
@ -127,8 +135,8 @@ class FileCacheTest extends TestCache {
|
|||
|
||||
public static function lockExceptionProvider(): array {
|
||||
return [
|
||||
[new \OCP\Lock\LockedException('key1')],
|
||||
[new \OCP\Files\LockNotAcquiredException('key1', 1)],
|
||||
[new LockedException('key1')],
|
||||
[new LockNotAcquiredException('key1', 1)],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use OC\AppFramework\Bootstrap\Coordinator;
|
|||
use OC\Calendar\AvailabilityResult;
|
||||
use OC\Calendar\Manager;
|
||||
use OCA\DAV\CalDAV\Auth\CustomPrincipalPlugin;
|
||||
use OCA\DAV\Connector\Sabre\Server;
|
||||
use OCA\DAV\ServerFactory;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Calendar\ICalendar;
|
||||
|
|
@ -1725,7 +1726,7 @@ EOF;
|
|||
->method('setCurrentPrincipal')
|
||||
->with('principals/users/admin');
|
||||
|
||||
$server = $this->createMock(\OCA\DAV\Connector\Sabre\Server::class);
|
||||
$server = $this->createMock(Server::class);
|
||||
$server->expects(self::once())
|
||||
->method('getPlugin')
|
||||
->with('auth')
|
||||
|
|
@ -1736,7 +1737,7 @@ EOF;
|
|||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
bool $sendResponse,
|
||||
) {
|
||||
): void {
|
||||
$requestBody = file_get_contents(__DIR__ . '/../../data/ics/free-busy-request.ics');
|
||||
$this->assertEquals('POST', $request->getMethod());
|
||||
$this->assertEquals('calendars/admin/outbox', $request->getPath());
|
||||
|
|
@ -1792,7 +1793,7 @@ EOF;
|
|||
->method('setCurrentPrincipal')
|
||||
->with('principals/users/admin');
|
||||
|
||||
$server = $this->createMock(\OCA\DAV\Connector\Sabre\Server::class);
|
||||
$server = $this->createMock(Server::class);
|
||||
$server->expects(self::once())
|
||||
->method('getPlugin')
|
||||
->with('auth')
|
||||
|
|
@ -1803,7 +1804,7 @@ EOF;
|
|||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
bool $sendResponse,
|
||||
) {
|
||||
): void {
|
||||
$requestBody = file_get_contents(__DIR__ . '/../../data/ics/free-busy-request.ics');
|
||||
$this->assertEquals('POST', $request->getMethod());
|
||||
$this->assertEquals('calendars/admin/outbox', $request->getPath());
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class CapabilitiesManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testInvalidCapability(): void {
|
||||
$this->manager->registerCapability(function () {
|
||||
$this->manager->registerCapability(function (): void {
|
||||
throw new QueryException();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -618,7 +618,7 @@ class MailPluginTest extends TestCase {
|
|||
|
||||
$this->groupManager->expects($this->any())
|
||||
->method('getUserGroupIds')
|
||||
->willReturnCallback(function (\OCP\IUser $user) use ($userToGroupMapping) {
|
||||
->willReturnCallback(function (IUser $user) use ($userToGroupMapping) {
|
||||
return $userToGroupMapping[$user->getUID()];
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,9 @@ class SimpleCommand implements ICommand {
|
|||
}
|
||||
|
||||
class StateFullCommand implements ICommand {
|
||||
private $state;
|
||||
|
||||
public function __construct($state) {
|
||||
$this->state = $state;
|
||||
public function __construct(
|
||||
private $state,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle() {
|
||||
|
|
@ -50,7 +49,7 @@ class ThisClosureTest {
|
|||
}
|
||||
|
||||
public function test(IBus $bus) {
|
||||
$bus->push(function () {
|
||||
$bus->push(function (): void {
|
||||
$this->privateMethod();
|
||||
});
|
||||
}
|
||||
|
|
@ -126,7 +125,7 @@ abstract class AsyncBusTestCase extends TestCase {
|
|||
}
|
||||
|
||||
public function testClosure(): void {
|
||||
$this->getBus()->push(function () {
|
||||
$this->getBus()->push(function (): void {
|
||||
AsyncBusTestCase::$lastCommand = 'closure';
|
||||
});
|
||||
$this->runJobs();
|
||||
|
|
@ -134,7 +133,7 @@ abstract class AsyncBusTestCase extends TestCase {
|
|||
}
|
||||
|
||||
public function testClosureSelf(): void {
|
||||
$this->getBus()->push(function () {
|
||||
$this->getBus()->push(function (): void {
|
||||
AsyncBusTestCase::$lastCommand = 'closure-self';
|
||||
});
|
||||
$this->runJobs();
|
||||
|
|
@ -152,7 +151,7 @@ abstract class AsyncBusTestCase extends TestCase {
|
|||
|
||||
public function testClosureBind(): void {
|
||||
$state = 'bar';
|
||||
$this->getBus()->push(function () use ($state) {
|
||||
$this->getBus()->push(function () use ($state): void {
|
||||
AsyncBusTestCase::$lastCommand = 'closure-' . $state;
|
||||
});
|
||||
$this->runJobs();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class SignAppTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) use (&$calls) {
|
||||
->willReturnCallback(function (string $message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
if ($expected === '*') {
|
||||
$this->assertNotEmpty($message);
|
||||
|
|
@ -91,7 +91,7 @@ class SignAppTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) use (&$calls) {
|
||||
->willReturnCallback(function (string $message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
if ($expected === '*') {
|
||||
$this->assertNotEmpty($message);
|
||||
|
|
@ -124,7 +124,7 @@ class SignAppTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) use (&$calls) {
|
||||
->willReturnCallback(function (string $message) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
if ($expected === '*') {
|
||||
$this->assertNotEmpty($message);
|
||||
|
|
@ -160,7 +160,7 @@ class SignAppTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Private key "privateKey" does not exists.', $message);
|
||||
});
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ class SignAppTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Certificate "certificate" does not exists.', $message);
|
||||
});
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ class SignAppTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Error: My error message', $message);
|
||||
});
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ class SignAppTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Successfully signed "AppId"', $message);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class SignCoreTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('--privateKey, --certificate and --path are required.', $message);
|
||||
});
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ class SignCoreTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('--privateKey, --certificate and --path are required.', $message);
|
||||
});
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ class SignCoreTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Private key "privateKey" does not exists.', $message);
|
||||
});
|
||||
|
||||
|
|
@ -131,7 +131,7 @@ class SignCoreTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Certificate "certificate" does not exists.', $message);
|
||||
});
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ class SignCoreTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Error: My exception message', $message);
|
||||
});
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ class SignCoreTest extends TestCase {
|
|||
$outputInterface
|
||||
->expects($this->any())
|
||||
->method('writeln')
|
||||
->willReturnCallback(function (string $message) {
|
||||
->willReturnCallback(function (string $message): void {
|
||||
$this->assertEquals('Successfully signed "core"', $message);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ namespace Test\Comments;
|
|||
|
||||
use OC\Comments\Comment;
|
||||
use OCP\Comments\IComment;
|
||||
use OCP\Comments\IllegalIDChangeException;
|
||||
use OCP\Comments\MessageTooLongException;
|
||||
use Test\TestCase;
|
||||
|
||||
class CommentTest extends TestCase {
|
||||
|
|
@ -62,7 +64,7 @@ class CommentTest extends TestCase {
|
|||
|
||||
|
||||
public function testSetIdIllegalInput(): void {
|
||||
$this->expectException(\OCP\Comments\IllegalIDChangeException::class);
|
||||
$this->expectException(IllegalIDChangeException::class);
|
||||
|
||||
$comment = new Comment();
|
||||
|
||||
|
|
@ -131,7 +133,7 @@ class CommentTest extends TestCase {
|
|||
|
||||
|
||||
public function testSetUberlongMessage(): void {
|
||||
$this->expectException(\OCP\Comments\MessageTooLongException::class);
|
||||
$this->expectException(MessageTooLongException::class);
|
||||
|
||||
$comment = new Comment();
|
||||
$msg = str_pad('', IComment::MAX_MESSAGE_LENGTH + 1, 'x');
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@
|
|||
*/
|
||||
namespace Test\Comments;
|
||||
|
||||
use OCP\Comments\ICommentsManagerFactory;
|
||||
use OCP\IServerContainer;
|
||||
|
||||
/**
|
||||
* Class FakeFactory
|
||||
*/
|
||||
class FakeFactory implements \OCP\Comments\ICommentsManagerFactory {
|
||||
class FakeFactory implements ICommentsManagerFactory {
|
||||
public function __construct(IServerContainer $serverContainer) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class ManagerTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->rootFolder = $this->createMock(IRootFolder::class);
|
||||
|
||||
$sql = $this->connection->getDatabasePlatform()->getTruncateTableSQL('`*PREFIX*comments`');
|
||||
|
|
@ -96,7 +96,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetCommentNotFound(): void {
|
||||
$this->expectException(\OCP\Comments\NotFoundException::class);
|
||||
$this->expectException(NotFoundException::class);
|
||||
|
||||
$manager = $this->getManager();
|
||||
$manager->get('22');
|
||||
|
|
@ -116,7 +116,7 @@ class ManagerTest extends TestCase {
|
|||
$creationDT = new \DateTime('yesterday');
|
||||
$latestChildDT = new \DateTime();
|
||||
|
||||
$qb = \OCP\Server::get(IDBConnection::class)->getQueryBuilder();
|
||||
$qb = Server::get(IDBConnection::class)->getQueryBuilder();
|
||||
$qb
|
||||
->insert('comments')
|
||||
->values([
|
||||
|
|
@ -158,7 +158,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetTreeNotFound(): void {
|
||||
$this->expectException(\OCP\Comments\NotFoundException::class);
|
||||
$this->expectException(NotFoundException::class);
|
||||
|
||||
$manager = $this->getManager();
|
||||
$manager->getTree('22');
|
||||
|
|
@ -450,7 +450,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
|
||||
public function testDelete(): void {
|
||||
$this->expectException(\OCP\Comments\NotFoundException::class);
|
||||
$this->expectException(NotFoundException::class);
|
||||
|
||||
$manager = $this->getManager();
|
||||
|
||||
|
|
@ -564,7 +564,7 @@ class ManagerTest extends TestCase {
|
|||
$manager->delete($comment->getId());
|
||||
|
||||
$comment->setMessage('very beautiful, I am really so much impressed!');
|
||||
$this->expectException(\OCP\Comments\NotFoundException::class);
|
||||
$this->expectException(NotFoundException::class);
|
||||
$manager->save($comment);
|
||||
}
|
||||
|
||||
|
|
@ -652,10 +652,10 @@ class ManagerTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testDeleteReferencesOfActorWithUserManagement(): void {
|
||||
$user = \OCP\Server::get(IUserManager::class)->createUser('xenia', 'NotAnEasyPassword123456+');
|
||||
$user = Server::get(IUserManager::class)->createUser('xenia', 'NotAnEasyPassword123456+');
|
||||
$this->assertInstanceOf(IUser::class, $user);
|
||||
|
||||
$manager = \OCP\Server::get(ICommentsManager::class);
|
||||
$manager = Server::get(ICommentsManager::class);
|
||||
$comment = $manager->create('users', $user->getUID(), 'files', 'file64');
|
||||
$comment
|
||||
->setMessage('Most important comment I ever left on the Internet.')
|
||||
|
|
@ -2425,7 +2425,7 @@ class ManagerTest extends TestCase {
|
|||
$expected = array_combine($keys, $expected);
|
||||
|
||||
if ($notFound) {
|
||||
$this->expectException(\OCP\Comments\NotFoundException::class);
|
||||
$this->expectException(NotFoundException::class);
|
||||
}
|
||||
$comment = $processedComments[$expected['message'] . '#' . $expected['actorId']];
|
||||
$actual = $manager->getReactionComment((int)$comment->getParentId(), $comment->getActorType(), $comment->getActorId(), $comment->getMessage());
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class LexiconTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$bootstrapCoordinator = \OCP\Server::get(Coordinator::class);
|
||||
$bootstrapCoordinator = Server::get(Coordinator::class);
|
||||
$bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestConfigLexicon_I::APPID, TestConfigLexicon_I::class);
|
||||
$bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestConfigLexicon_N::APPID, TestConfigLexicon_N::class);
|
||||
$bootstrapCoordinator->getRegistrationContext()?->registerConfigLexicon(TestConfigLexicon_W::APPID, TestConfigLexicon_W::class);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use OC\Config\UserConfig;
|
|||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Security\ICrypto;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -170,10 +171,10 @@ class UserConfigTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OCP\Server::get(IDBConnection::class);
|
||||
$this->config = \OCP\Server::get(IConfig::class);
|
||||
$this->logger = \OCP\Server::get(LoggerInterface::class);
|
||||
$this->crypto = \OCP\Server::get(ICrypto::class);
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->config = Server::get(IConfig::class);
|
||||
$this->logger = Server::get(LoggerInterface::class);
|
||||
$this->crypto = Server::get(ICrypto::class);
|
||||
|
||||
// storing current preferences and emptying the data table
|
||||
$sql = $this->connection->getQueryBuilder();
|
||||
|
|
@ -278,7 +279,7 @@ class UserConfigTest extends TestCase {
|
|||
* @return IUserConfig
|
||||
*/
|
||||
private function generateUserConfig(array $preLoading = []): IUserConfig {
|
||||
$userConfig = new \OC\Config\UserConfig(
|
||||
$userConfig = new UserConfig(
|
||||
$this->connection,
|
||||
$this->config,
|
||||
$this->logger,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
namespace Test;
|
||||
|
||||
use OC\Config;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
|
||||
class ConfigTest extends TestCase {
|
||||
public const TESTCONTENT = '<?php $CONFIG=array("foo"=>"bar", "beers" => array("Appenzeller", "Guinness", "Kölsch"), "alcohol_free" => false);';
|
||||
|
|
@ -22,7 +24,7 @@ class ConfigTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->randomTmpDir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$this->randomTmpDir = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
$this->configFile = $this->randomTmpDir . 'testconfig.php';
|
||||
file_put_contents($this->configFile, self::TESTCONTENT);
|
||||
}
|
||||
|
|
@ -33,7 +35,7 @@ class ConfigTest extends TestCase {
|
|||
}
|
||||
|
||||
private function getConfig(): Config {
|
||||
return new \OC\Config($this->randomTmpDir, 'testconfig.php');
|
||||
return new Config($this->randomTmpDir, 'testconfig.php');
|
||||
}
|
||||
|
||||
public function testGetKeys(): void {
|
||||
|
|
@ -159,7 +161,7 @@ class ConfigTest extends TestCase {
|
|||
file_put_contents($additionalConfigPath, $additionalConfig);
|
||||
|
||||
// Reinstantiate the config to force a read-in of the additional configs
|
||||
$config = new \OC\Config($this->randomTmpDir, 'testconfig.php');
|
||||
$config = new Config($this->randomTmpDir, 'testconfig.php');
|
||||
|
||||
// Ensure that the config value can be read and the config has not been modified
|
||||
$this->assertSame('totallyOutdated', $config->getValue('php53', 'bogusValue'));
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
namespace Test;
|
||||
|
||||
use OC\ContactsManager;
|
||||
use OCP\Constants;
|
||||
use OCP\IAddressBook;
|
||||
|
||||
class ContactsManagerTest extends \Test\TestCase {
|
||||
|
|
@ -14,7 +16,7 @@ class ContactsManagerTest extends \Test\TestCase {
|
|||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->cm = new \OC\ContactsManager();
|
||||
$this->cm = new ContactsManager();
|
||||
}
|
||||
|
||||
public static function searchProvider(): array {
|
||||
|
|
@ -153,7 +155,7 @@ class ContactsManagerTest extends \Test\TestCase {
|
|||
|
||||
$addressbook->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn(\OCP\Constants::PERMISSION_ALL);
|
||||
->willReturn(Constants::PERMISSION_ALL);
|
||||
|
||||
$addressbook->expects($this->once())
|
||||
->method('delete')
|
||||
|
|
@ -176,7 +178,7 @@ class ContactsManagerTest extends \Test\TestCase {
|
|||
|
||||
$addressbook->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn(\OCP\Constants::PERMISSION_READ);
|
||||
->willReturn(Constants::PERMISSION_READ);
|
||||
|
||||
$addressbook->expects($this->never())
|
||||
->method('delete');
|
||||
|
|
@ -216,7 +218,7 @@ class ContactsManagerTest extends \Test\TestCase {
|
|||
|
||||
$addressbook->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn(\OCP\Constants::PERMISSION_ALL);
|
||||
->willReturn(Constants::PERMISSION_ALL);
|
||||
|
||||
$addressbook->expects($this->once())
|
||||
->method('createOrUpdate')
|
||||
|
|
@ -239,7 +241,7 @@ class ContactsManagerTest extends \Test\TestCase {
|
|||
|
||||
$addressbook->expects($this->any())
|
||||
->method('getPermissions')
|
||||
->willReturn(\OCP\Constants::PERMISSION_READ);
|
||||
->willReturn(Constants::PERMISSION_READ);
|
||||
|
||||
$addressbook->expects($this->never())
|
||||
->method('createOrUpdate');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
namespace Test\DB;
|
||||
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
use Test\TestCase;
|
||||
|
||||
class AdapterTest extends TestCase {
|
||||
|
|
@ -13,7 +15,7 @@ class AdapterTest extends TestCase {
|
|||
private $connection;
|
||||
|
||||
public function setUp(): void {
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->appId = uniqid('test_db_adapter', true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ class MigrationsTest extends \Test\TestCase {
|
|||
];
|
||||
$this->migrationService->expects($this->exactly(2))
|
||||
->method('executeStep')
|
||||
->willReturnCallback(function () use (&$calls) {
|
||||
->willReturnCallback(function () use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, func_get_args());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@ use OC\DB\Migrator;
|
|||
use OC\DB\OracleMigrator;
|
||||
use OC\DB\SQLiteMigrator;
|
||||
use OCP\DB\Types;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
|
||||
/**
|
||||
* Class MigratorTest
|
||||
|
|
@ -46,15 +48,15 @@ class MigratorTest extends \Test\TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->config = \OC::$server->getConfig();
|
||||
$this->connection = \OC::$server->get(\OC\DB\Connection::class);
|
||||
$this->config = Server::get(IConfig::class);
|
||||
$this->connection = Server::get(\OC\DB\Connection::class);
|
||||
|
||||
$this->tableName = $this->getUniqueTableName();
|
||||
$this->tableNameTmp = $this->getUniqueTableName();
|
||||
}
|
||||
|
||||
private function getMigrator(): Migrator {
|
||||
$dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
|
||||
$dispatcher = Server::get(IEventDispatcher::class);
|
||||
if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
|
||||
return new SQLiteMigrator($this->connection, $this->config, $dispatcher);
|
||||
} elseif ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ class ExpressionBuilderDBTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->prepareTestingTable();
|
||||
}
|
||||
|
||||
public static function likeProvider(): array {
|
||||
$connection = \OCP\Server::get(IDBConnection::class);
|
||||
$connection = Server::get(IDBConnection::class);
|
||||
|
||||
return [
|
||||
['foo', 'bar', false],
|
||||
|
|
@ -67,7 +67,7 @@ class ExpressionBuilderDBTest extends TestCase {
|
|||
}
|
||||
|
||||
public static function ilikeProvider(): array {
|
||||
$connection = \OCP\Server::get(IDBConnection::class);
|
||||
$connection = Server::get(IDBConnection::class);
|
||||
|
||||
return [
|
||||
['foo', 'bar', false],
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ namespace Test\DB\QueryBuilder;
|
|||
use Doctrine\DBAL\Query\Expression\ExpressionBuilder as DoctrineExpressionBuilder;
|
||||
use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -39,8 +41,8 @@ class ExpressionBuilderTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->internalConnection = \OC::$server->get(\OC\DB\Connection::class);
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->internalConnection = Server::get(\OC\DB\Connection::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
|
||||
$queryBuilder = $this->createMock(IQueryBuilder::class);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ namespace Test\DB\QueryBuilder;
|
|||
|
||||
use OC\DB\QueryBuilder\Literal;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -24,7 +26,7 @@ class FunctionBuilderTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use OCP\DB\IResult;
|
|||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\DB\QueryBuilder\IQueryFunction;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
|
|
@ -42,7 +43,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->config = $this->createMock(SystemConfig::class);
|
||||
$this->logger = $this->createMock(LoggerInterface::class);
|
||||
$this->queryBuilder = new QueryBuilder($this->connection, $this->config, $this->logger);
|
||||
|
|
@ -164,7 +165,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
public function dataSelect(): array {
|
||||
$config = $this->createMock(SystemConfig::class);
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
|
||||
$queryBuilder = new QueryBuilder(Server::get(IDBConnection::class), $config, $logger);
|
||||
return [
|
||||
// select('column1')
|
||||
[['configvalue'], ['configvalue' => '99']],
|
||||
|
|
@ -232,7 +233,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
public function dataSelectAlias(): array {
|
||||
$config = $this->createMock(SystemConfig::class);
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
|
||||
$queryBuilder = new QueryBuilder(Server::get(IDBConnection::class), $config, $logger);
|
||||
return [
|
||||
['configvalue', 'cv', ['cv' => '99']],
|
||||
[$queryBuilder->expr()->literal('column1'), 'thing', ['thing' => 'column1']],
|
||||
|
|
@ -341,7 +342,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
public function dataAddSelect(): array {
|
||||
$config = $this->createMock(SystemConfig::class);
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
|
||||
$queryBuilder = new QueryBuilder(Server::get(IDBConnection::class), $config, $logger);
|
||||
return [
|
||||
// addSelect('column1')
|
||||
[['configvalue'], ['appid' => 'testFirstResult', 'configvalue' => '99']],
|
||||
|
|
@ -496,7 +497,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
public function dataFrom(): array {
|
||||
$config = $this->createMock(SystemConfig::class);
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$qb = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
|
||||
$qb = new QueryBuilder(Server::get(IDBConnection::class), $config, $logger);
|
||||
return [
|
||||
[$qb->createFunction('(' . $qb->select('*')->from('test')->getSQL() . ')'), 'q', null, null, [
|
||||
['table' => '(SELECT * FROM `*PREFIX*test`)', 'alias' => '`q`']
|
||||
|
|
@ -1200,7 +1201,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
public function dataGetTableName(): array {
|
||||
$config = $this->createMock(SystemConfig::class);
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$qb = new QueryBuilder(\OC::$server->getDatabaseConnection(), $config, $logger);
|
||||
$qb = new QueryBuilder(Server::get(IDBConnection::class), $config, $logger);
|
||||
return [
|
||||
['*PREFIX*table', null, '`*PREFIX*table`'],
|
||||
['*PREFIX*table', true, '`*PREFIX*table`'],
|
||||
|
|
@ -1427,7 +1428,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
$this->logger
|
||||
->expects($this->once())
|
||||
->method('error')
|
||||
->willReturnCallback(function ($message, $parameters) {
|
||||
->willReturnCallback(function ($message, $parameters): void {
|
||||
$this->assertInstanceOf(QueryException::class, $parameters['exception']);
|
||||
$this->assertSame(
|
||||
'More than 1000 expressions in a list are not allowed on Oracle.',
|
||||
|
|
@ -1462,7 +1463,7 @@ class QueryBuilderTest extends \Test\TestCase {
|
|||
$this->logger
|
||||
->expects($this->once())
|
||||
->method('error')
|
||||
->willReturnCallback(function ($message, $parameters) {
|
||||
->willReturnCallback(function ($message, $parameters): void {
|
||||
$this->assertInstanceOf(QueryException::class, $parameters['exception']);
|
||||
$this->assertSame(
|
||||
'The number of parameters must not exceed 65535. Restriction by PostgreSQL.',
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
namespace Test;
|
||||
|
||||
use OC\DateTimeFormatter;
|
||||
use OCP\Util;
|
||||
|
||||
class DateTimeFormatterTest extends TestCase {
|
||||
/** @var \OC\DateTimeFormatter */
|
||||
protected $formatter;
|
||||
|
|
@ -33,7 +36,7 @@ class DateTimeFormatterTest extends TestCase {
|
|||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->formatter = new \OC\DateTimeFormatter(new \DateTimeZone('UTC'), \OCP\Util::getL10N('lib', 'en'));
|
||||
$this->formatter = new DateTimeFormatter(new \DateTimeZone('UTC'), Util::getL10N('lib', 'en'));
|
||||
}
|
||||
|
||||
protected static function getTimestampAgo($time, $seconds = 0, $minutes = 0, $hours = 0, $days = 0, $years = 0) {
|
||||
|
|
@ -42,7 +45,7 @@ class DateTimeFormatterTest extends TestCase {
|
|||
|
||||
public static function formatTimeSpanData(): array {
|
||||
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
|
||||
$deL10N = \OCP\Util::getL10N('lib', 'de');
|
||||
$deL10N = Util::getL10N('lib', 'de');
|
||||
return [
|
||||
['seconds ago', $time, $time],
|
||||
['in a few seconds', $time + 5 , $time],
|
||||
|
|
@ -83,7 +86,7 @@ class DateTimeFormatterTest extends TestCase {
|
|||
|
||||
public static function formatDateSpanData(): array {
|
||||
$time = 1416916800; // Use a fixed timestamp so we don't switch days/years with the getTimestampAgo
|
||||
$deL10N = \OCP\Util::getL10N('lib', 'de');
|
||||
$deL10N = Util::getL10N('lib', 'de');
|
||||
return [
|
||||
// Normal testing
|
||||
['today', self::getTimestampAgo($time, 30, 15), $time],
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use OCP\IUser;
|
|||
use OCP\IUserSession;
|
||||
use OCP\L10N\IFactory;
|
||||
use OCP\Security\ISecureRandom;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
|
|
@ -124,7 +125,7 @@ class ManagerTest extends TestCase {
|
|||
$this->editor = new Editor();
|
||||
|
||||
$this->random = $this->createMock(ISecureRandom::class);
|
||||
$this->connection = \OC::$server->getDatabaseConnection();
|
||||
$this->connection = Server::get(IDBConnection::class);
|
||||
$this->userSession = $this->createMock(IUserSession::class);
|
||||
$this->rootFolder = $this->createMock(IRootFolder::class);
|
||||
$this->userFolder = $this->createMock(Folder::class);
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ class DecryptAllTest extends TestCase {
|
|||
];
|
||||
$instance->expects($this->exactly(2))
|
||||
->method('decryptUsersFiles')
|
||||
->willReturnCallback(function ($user) use (&$calls) {
|
||||
->willReturnCallback(function ($user) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, $user);
|
||||
});
|
||||
|
|
@ -297,7 +297,7 @@ class DecryptAllTest extends TestCase {
|
|||
];
|
||||
$instance->expects($this->exactly(2))
|
||||
->method('decryptFile')
|
||||
->willReturnCallback(function ($path) use (&$calls) {
|
||||
->willReturnCallback(function ($path) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, $path);
|
||||
});
|
||||
|
|
@ -387,7 +387,7 @@ class DecryptAllTest extends TestCase {
|
|||
$this->view->expects($this->once())
|
||||
->method('copy')
|
||||
->with($path, $path . '.decrypted.42')
|
||||
->willReturnCallback(function () {
|
||||
->willReturnCallback(function (): void {
|
||||
throw new DecryptionFailedException();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ class StorageTest extends TestCase {
|
|||
'user1/files_encryption/backup/test.encryptionModule.1234567',
|
||||
];
|
||||
$this->view->expects($this->exactly(2))->method('mkdir')
|
||||
->willReturnCallback(function ($path) use (&$calls) {
|
||||
->willReturnCallback(function ($path) use (&$calls): void {
|
||||
$expected = array_shift($calls);
|
||||
$this->assertEquals($expected, $path);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
namespace Test\Encryption;
|
||||
|
||||
use OC\Encryption\Exceptions\ModuleAlreadyExistsException;
|
||||
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
|
||||
use OC\Encryption\Manager;
|
||||
use OC\Encryption\Util;
|
||||
use OC\Files\View;
|
||||
|
|
@ -88,7 +90,7 @@ class ManagerTest extends TestCase {
|
|||
* @depends testModuleRegistration
|
||||
*/
|
||||
public function testModuleReRegistration($manager): void {
|
||||
$this->expectException(\OC\Encryption\Exceptions\ModuleAlreadyExistsException::class);
|
||||
$this->expectException(ModuleAlreadyExistsException::class);
|
||||
$this->expectExceptionMessage('Id "ID0" already used by encryption module "TestDummyModule0"');
|
||||
|
||||
$this->addNewEncryptionModule($manager, 0);
|
||||
|
|
@ -105,7 +107,7 @@ class ManagerTest extends TestCase {
|
|||
|
||||
|
||||
public function testGetEncryptionModuleUnknown(): void {
|
||||
$this->expectException(\OC\Encryption\Exceptions\ModuleDoesNotExistsException::class);
|
||||
$this->expectException(ModuleDoesNotExistsException::class);
|
||||
$this->expectExceptionMessage('Module with ID: unknown does not exist.');
|
||||
|
||||
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
namespace Test\Encryption;
|
||||
|
||||
use OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException;
|
||||
use OC\Encryption\Util;
|
||||
use OC\Files\View;
|
||||
use OCP\Encryption\IEncryptionModule;
|
||||
|
|
@ -91,7 +92,7 @@ class UtilTest extends TestCase {
|
|||
|
||||
|
||||
public function testCreateHeaderFailed(): void {
|
||||
$this->expectException(\OC\Encryption\Exceptions\EncryptionHeaderKeyExistsException::class);
|
||||
$this->expectException(EncryptionHeaderKeyExistsException::class);
|
||||
|
||||
|
||||
$header = ['header1' => 1, 'header2' => 2, 'oc_encryption_module' => 'foo'];
|
||||
|
|
|
|||
|
|
@ -11,13 +11,18 @@ use OC\Files\Cache\Cache;
|
|||
use OC\Files\Cache\CacheEntry;
|
||||
use OC\Files\Search\SearchComparison;
|
||||
use OC\Files\Search\SearchQuery;
|
||||
use OC\Files\Storage\Temporary;
|
||||
use OC\User\User;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Files\Cache\ICacheEntry;
|
||||
use OCP\Files\Search\ISearchComparison;
|
||||
use OCP\IDBConnection;
|
||||
use OCP\ITagManager;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Server;
|
||||
|
||||
class LongId extends \OC\Files\Storage\Temporary {
|
||||
class LongId extends Temporary {
|
||||
public function getId(): string {
|
||||
return 'long:' . str_repeat('foo', 50) . parent::getId();
|
||||
}
|
||||
|
|
@ -52,10 +57,10 @@ class CacheTest extends \Test\TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->storage = new \OC\Files\Storage\Temporary([]);
|
||||
$this->storage2 = new \OC\Files\Storage\Temporary([]);
|
||||
$this->cache = new \OC\Files\Cache\Cache($this->storage);
|
||||
$this->cache2 = new \OC\Files\Cache\Cache($this->storage2);
|
||||
$this->storage = new Temporary([]);
|
||||
$this->storage2 = new Temporary([]);
|
||||
$this->cache = new Cache($this->storage);
|
||||
$this->cache2 = new Cache($this->storage2);
|
||||
$this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
|
||||
$this->cache2->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
|
||||
}
|
||||
|
|
@ -162,8 +167,8 @@ class CacheTest extends \Test\TestCase {
|
|||
public function testFolder($folder): void {
|
||||
if (strpos($folder, 'F09F9890')) {
|
||||
// 4 byte UTF doesn't work on mysql
|
||||
$params = \OC::$server->get(\OC\DB\Connection::class)->getParams();
|
||||
if (\OC::$server->getDatabaseConnection()->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL && $params['charset'] !== 'utf8mb4') {
|
||||
$params = Server::get(\OC\DB\Connection::class)->getParams();
|
||||
if (Server::get(IDBConnection::class)->getDatabaseProvider() === IDBConnection::PLATFORM_MYSQL && $params['charset'] !== 'utf8mb4') {
|
||||
$this->markTestSkipped('MySQL doesn\'t support 4 byte UTF-8');
|
||||
}
|
||||
}
|
||||
|
|
@ -311,13 +316,13 @@ class CacheTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testStatus(): void {
|
||||
$this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->getStatus('foo'));
|
||||
$this->assertEquals(Cache::NOT_FOUND, $this->cache->getStatus('foo'));
|
||||
$this->cache->put('foo', ['size' => -1]);
|
||||
$this->assertEquals(\OC\Files\Cache\Cache::PARTIAL, $this->cache->getStatus('foo'));
|
||||
$this->assertEquals(Cache::PARTIAL, $this->cache->getStatus('foo'));
|
||||
$this->cache->put('foo', ['size' => -1, 'mtime' => 20, 'mimetype' => 'foo/file']);
|
||||
$this->assertEquals(\OC\Files\Cache\Cache::SHALLOW, $this->cache->getStatus('foo'));
|
||||
$this->assertEquals(Cache::SHALLOW, $this->cache->getStatus('foo'));
|
||||
$this->cache->put('foo', ['size' => 10]);
|
||||
$this->assertEquals(\OC\Files\Cache\Cache::COMPLETE, $this->cache->getStatus('foo'));
|
||||
$this->assertEquals(Cache::COMPLETE, $this->cache->getStatus('foo'));
|
||||
}
|
||||
|
||||
public static function putWithAllKindOfQuotesData(): array {
|
||||
|
|
@ -333,7 +338,7 @@ class CacheTest extends \Test\TestCase {
|
|||
* @param $fileName
|
||||
*/
|
||||
public function testPutWithAllKindOfQuotes($fileName): void {
|
||||
$this->assertEquals(\OC\Files\Cache\Cache::NOT_FOUND, $this->cache->get($fileName));
|
||||
$this->assertEquals(Cache::NOT_FOUND, $this->cache->get($fileName));
|
||||
$this->cache->put($fileName, ['size' => 20, 'mtime' => 25, 'mimetype' => 'foo/file', 'etag' => $fileName]);
|
||||
|
||||
$cacheEntry = $this->cache->get($fileName);
|
||||
|
|
@ -371,9 +376,9 @@ class CacheTest extends \Test\TestCase {
|
|||
|
||||
public function testSearchQueryByTag(): void {
|
||||
$userId = static::getUniqueID('user');
|
||||
\OC::$server->getUserManager()->createUser($userId, $userId);
|
||||
Server::get(IUserManager::class)->createUser($userId, $userId);
|
||||
static::loginAsUser($userId);
|
||||
$user = new \OC\User\User($userId, null, \OC::$server->get(IEventDispatcher::class));
|
||||
$user = new User($userId, null, Server::get(IEventDispatcher::class));
|
||||
|
||||
$file1 = 'folder';
|
||||
$file2 = 'folder/foobar';
|
||||
|
|
@ -393,7 +398,7 @@ class CacheTest extends \Test\TestCase {
|
|||
$id4 = $this->cache->put($file4, $fileData['foo2']);
|
||||
$id5 = $this->cache->put($file5, $fileData['foo3']);
|
||||
|
||||
$tagManager = \OCP\Server::get(\OCP\ITagManager::class)->load('files', [], false, $userId);
|
||||
$tagManager = Server::get(ITagManager::class)->load('files', [], false, $userId);
|
||||
$this->assertTrue($tagManager->tagAs($id1, 'tag1'));
|
||||
$this->assertTrue($tagManager->tagAs($id1, 'tag2'));
|
||||
$this->assertTrue($tagManager->tagAs($id2, 'tag2'));
|
||||
|
|
@ -418,7 +423,7 @@ class CacheTest extends \Test\TestCase {
|
|||
$tagManager->delete('tag2');
|
||||
|
||||
static::logout();
|
||||
$user = \OC::$server->getUserManager()->get($userId);
|
||||
$user = Server::get(IUserManager::class)->get($userId);
|
||||
if ($user !== null) {
|
||||
try {
|
||||
$user->delete();
|
||||
|
|
@ -550,7 +555,7 @@ class CacheTest extends \Test\TestCase {
|
|||
if (strlen($storageId) > 64) {
|
||||
$storageId = md5($storageId);
|
||||
}
|
||||
$this->assertEquals([$storageId, 'foo'], \OC\Files\Cache\Cache::getById($id));
|
||||
$this->assertEquals([$storageId, 'foo'], Cache::getById($id));
|
||||
}
|
||||
|
||||
public function testStorageMTime(): void {
|
||||
|
|
@ -577,7 +582,7 @@ class CacheTest extends \Test\TestCase {
|
|||
$storageId = $storage->getId();
|
||||
$data = ['size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file'];
|
||||
$id = $cache->put('foo', $data);
|
||||
$this->assertEquals([md5($storageId), 'foo'], \OC\Files\Cache\Cache::getById($id));
|
||||
$this->assertEquals([md5($storageId), 'foo'], Cache::getById($id));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,24 +7,20 @@
|
|||
|
||||
namespace Test\Files\Cache;
|
||||
|
||||
class DummyUser extends \OC\User\User {
|
||||
/**
|
||||
* @var string $home
|
||||
*/
|
||||
private $home;
|
||||
|
||||
/**
|
||||
* @var string $uid
|
||||
*/
|
||||
private $uid;
|
||||
use OC\Files\Storage\Home;
|
||||
use OC\User\User;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
|
||||
class DummyUser extends User {
|
||||
/**
|
||||
* @param string $uid
|
||||
* @param string $home
|
||||
*/
|
||||
public function __construct($uid, $home) {
|
||||
$this->home = $home;
|
||||
$this->uid = $uid;
|
||||
public function __construct(
|
||||
private $uid,
|
||||
private $home,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -68,8 +64,8 @@ class HomeCacheTest extends \Test\TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->user = new DummyUser('foo', \OC::$server->getTempManager()->getTemporaryFolder());
|
||||
$this->storage = new \OC\Files\Storage\Home(['user' => $this->user]);
|
||||
$this->user = new DummyUser('foo', Server::get(ITempManager::class)->getTemporaryFolder());
|
||||
$this->storage = new Home(['user' => $this->user]);
|
||||
$this->cache = $this->storage->getCache();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ declare(strict_types=1);
|
|||
namespace Test\Files\Cache;
|
||||
|
||||
use OC\Files\Storage\LocalRootStorage;
|
||||
use OCP\ITempManager;
|
||||
use OCP\Server;
|
||||
use Test\TestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -21,7 +23,7 @@ class LocalRootScannerTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$folder = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$folder = Server::get(ITempManager::class)->getTemporaryFolder();
|
||||
$this->storage = new LocalRootStorage(['datadir' => $folder]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue