chore: run rector on tests with new rule

Signed-off-by: Robin Appelman <robin@icewind.nl>
pull/53459/head
Robin Appelman 4 months ago
parent 3cc34ac29d
commit 3561937816
No known key found for this signature in database
GPG Key ID: 42B69D8A64526EFB
  1. 4
      tests/Core/Command/User/AddTest.php
  2. 12
      tests/Core/Controller/AvatarControllerTest.php
  3. 2
      tests/Core/Controller/ChangePasswordControllerTest.php
  4. 2
      tests/Core/Controller/LostControllerTest.php
  5. 2
      tests/Core/Controller/TwoFactorChallengeControllerTest.php
  6. 2
      tests/lib/AppFramework/Http/DispatcherTest.php
  7. 2
      tests/lib/AppFramework/Middleware/Security/CORSMiddlewareTest.php
  8. 14
      tests/lib/Authentication/LoginCredentials/StoreTest.php
  9. 8
      tests/lib/BinaryFinderTest.php
  10. 6
      tests/lib/Cache/FileCacheTest.php
  11. 6
      tests/lib/Calendar/ResourcesRoomsUpdaterTest.php
  12. 8
      tests/lib/Contacts/ContactsMenu/Providers/LocalTimeProviderTest.php
  13. 2
      tests/lib/Files/Mount/MountPointTest.php
  14. 2
      tests/lib/Files/Node/FolderTest.php
  15. 4
      tests/lib/Files/Node/NodeTestCase.php
  16. 4
      tests/lib/Files/Storage/Wrapper/AvailabilityTest.php
  17. 8
      tests/lib/Files/ViewTest.php
  18. 15
      tests/lib/Group/MetaDataTest.php
  19. 20
      tests/lib/Http/Client/ClientTest.php
  20. 6
      tests/lib/IntegrityCheck/CheckerTest.php
  21. 8
      tests/lib/LoggerTest.php
  22. 9
      tests/lib/Repair/Owncloud/CleanPreviewsBackgroundJobTest.php
  23. 4
      tests/lib/Repair/Owncloud/CleanPreviewsTest.php
  24. 2
      tests/lib/RepairTest.php
  25. 4
      tests/lib/Template/ResourceLocatorTest.php
  26. 4
      tests/lib/Traits/MountProviderTrait.php
  27. 20
      tests/lib/User/SessionTest.php
  28. 8
      tests/lib/User/UserTest.php

@ -111,11 +111,11 @@ class AddTest extends TestCase {
->method('sendMail'); ->method('sendMail');
$this->consoleInput->method('getOption') $this->consoleInput->method('getOption')
->will(static::returnValueMap([ ->willReturnMap([
['generate-password', 'true'], ['generate-password', 'true'],
['email', $email], ['email', $email],
['group', []], ['group', []],
])); ]);
$this->invokePrivate($this->addCommand, 'execute', [ $this->invokePrivate($this->addCommand, 'execute', [
$this->consoleInput, $this->consoleInput,

@ -130,7 +130,7 @@ class AvatarControllerTest extends \Test\TestCase {
*/ */
public function testGetAvatarNoAvatar(): void { public function testGetAvatarNoAvatar(): void {
$this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
$this->avatarMock->method('getFile')->will($this->throwException(new NotFoundException())); $this->avatarMock->method('getFile')->willThrowException(new NotFoundException());
$response = $this->avatarController->getAvatar('userId', 32); $response = $this->avatarController->getAvatar('userId', 32);
//Comment out until JS is fixed //Comment out until JS is fixed
@ -183,7 +183,7 @@ class AvatarControllerTest extends \Test\TestCase {
$this->avatarManager $this->avatarManager
->method('getAvatar') ->method('getAvatar')
->with('userDoesNotExist') ->with('userDoesNotExist')
->will($this->throwException(new \Exception('user does not exist'))); ->willThrowException(new \Exception('user does not exist'));
$response = $this->avatarController->getAvatar('userDoesNotExist', 32); $response = $this->avatarController->getAvatar('userDoesNotExist', 32);
@ -287,7 +287,7 @@ class AvatarControllerTest extends \Test\TestCase {
* Test what happens if the removing of the avatar fails * Test what happens if the removing of the avatar fails
*/ */
public function testDeleteAvatarException(): void { public function testDeleteAvatarException(): void {
$this->avatarMock->method('remove')->will($this->throwException(new \Exception('foo'))); $this->avatarMock->method('remove')->willThrowException(new \Exception('foo'));
$this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
$this->logger->expects($this->once()) $this->logger->expects($this->once())
@ -469,7 +469,7 @@ class AvatarControllerTest extends \Test\TestCase {
public function testPostAvatarException(): void { public function testPostAvatarException(): void {
$this->cache->expects($this->once()) $this->cache->expects($this->once())
->method('set') ->method('set')
->will($this->throwException(new \Exception('foo'))); ->willThrowException(new \Exception('foo'));
$file = $this->getMockBuilder('OCP\Files\File') $file = $this->getMockBuilder('OCP\Files\File')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
$file->expects($this->once()) $file->expects($this->once())
@ -514,7 +514,7 @@ class AvatarControllerTest extends \Test\TestCase {
public function testPostCroppedAvatarNoSquareCrop(): void { public function testPostCroppedAvatarNoSquareCrop(): void {
$this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg')); $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->avatarMock->method('set')->will($this->throwException(new \OC\NotSquareException)); $this->avatarMock->method('set')->willThrowException(new \OC\NotSquareException);
$this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
$response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11]); $response = $this->avatarController->postCroppedAvatar(['x' => 0, 'y' => 0, 'w' => 10, 'h' => 11]);
@ -539,7 +539,7 @@ class AvatarControllerTest extends \Test\TestCase {
public function testPostCroppedAvatarException(): void { public function testPostCroppedAvatarException(): void {
$this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg')); $this->cache->method('get')->willReturn(file_get_contents(\OC::$SERVERROOT . '/tests/data/testimage.jpg'));
$this->avatarMock->method('set')->will($this->throwException(new \Exception('foo'))); $this->avatarMock->method('set')->willThrowException(new \Exception('foo'));
$this->avatarManager->method('getAvatar')->willReturn($this->avatarMock); $this->avatarManager->method('getAvatar')->willReturn($this->avatarMock);
$this->logger->expects($this->once()) $this->logger->expects($this->once())

@ -96,7 +96,7 @@ class ChangePasswordControllerTest extends \Test\TestCase {
$user->expects($this->once()) $user->expects($this->once())
->method('setPassword') ->method('setPassword')
->with('new') ->with('new')
->will($this->throwException(new HintException('Common password'))); ->willThrowException(new HintException('Common password'));
$expects = new JSONResponse([ $expects = new JSONResponse([
'status' => 'error', 'status' => 'error',

@ -403,7 +403,7 @@ class LostControllerTest extends TestCase {
->expects($this->once()) ->expects($this->once())
->method('send') ->method('send')
->with($message) ->with($message)
->will($this->throwException(new \Exception())); ->willThrowException(new \Exception());
$this->logger->expects($this->exactly(1)) $this->logger->expects($this->exactly(1))
->method('error'); ->method('error');

@ -301,7 +301,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
$this->twoFactorManager->expects($this->once()) $this->twoFactorManager->expects($this->once())
->method('verifyChallenge') ->method('verifyChallenge')
->with('myprovider', $user, 'token') ->with('myprovider', $user, 'token')
->will($this->throwException($exception)); ->willThrowException($exception);
$calls = [ $calls = [
['two_factor_auth_error_message', '2FA failed'], ['two_factor_auth_error_message', '2FA failed'],
['two_factor_auth_error', true], ['two_factor_auth_error', true],

@ -157,7 +157,7 @@ class DispatcherTest extends \Test\TestCase {
->method('beforeController') ->method('beforeController')
->with($this->equalTo($this->controller), ->with($this->equalTo($this->controller),
$this->equalTo($this->controllerMethod)) $this->equalTo($this->controllerMethod))
->will($this->throwException($exception)); ->willThrowException($exception);
if ($catchEx) { if ($catchEx) {
$this->middlewareDispatcher->expects($this->once()) $this->middlewareDispatcher->expects($this->once())
->method('afterException') ->method('afterException')

@ -269,7 +269,7 @@ class CORSMiddlewareTest extends \Test\TestCase {
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('logClientIn') ->method('logClientIn')
->with($this->equalTo('user'), $this->equalTo('pass')) ->with($this->equalTo('user'), $this->equalTo('pass'))
->will($this->throwException(new PasswordLoginForbiddenException)); ->willThrowException(new PasswordLoginForbiddenException);
$this->reflector->reflect($this->controller, $method); $this->reflector->reflect($this->controller, $method);
$middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler, $this->logger); $middleware = new CORSMiddleware($request, $this->reflector, $this->session, $this->throttler, $this->logger);

@ -111,7 +111,7 @@ class StoreTest extends TestCase {
public function testGetLoginCredentialsSessionNotAvailable(): void { public function testGetLoginCredentialsSessionNotAvailable(): void {
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('getId') ->method('getId')
->will($this->throwException(new SessionNotAvailableException())); ->willThrowException(new SessionNotAvailableException());
$this->expectException(CredentialsUnavailableException::class); $this->expectException(CredentialsUnavailableException::class);
$this->store->getLoginCredentials(); $this->store->getLoginCredentials();
@ -124,7 +124,7 @@ class StoreTest extends TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('sess2233') ->with('sess2233')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->expectException(CredentialsUnavailableException::class); $this->expectException(CredentialsUnavailableException::class);
$this->store->getLoginCredentials(); $this->store->getLoginCredentials();
@ -141,7 +141,7 @@ class StoreTest extends TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('sess2233') ->with('sess2233')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('exists') ->method('exists')
->with($this->equalTo('login_credentials')) ->with($this->equalTo('login_credentials'))
@ -181,7 +181,7 @@ class StoreTest extends TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('sess2233') ->with('sess2233')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('exists') ->method('exists')
->with($this->equalTo('login_credentials')) ->with($this->equalTo('login_credentials'))
@ -222,7 +222,7 @@ class StoreTest extends TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('sess2233') ->with('sess2233')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('exists') ->method('exists')
->with($this->equalTo('login_credentials')) ->with($this->equalTo('login_credentials'))
@ -248,7 +248,7 @@ class StoreTest extends TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('sess2233') ->with('sess2233')
->will($this->throwException(new PasswordlessTokenException())); ->willThrowException(new PasswordlessTokenException());
$this->expectException(CredentialsUnavailableException::class); $this->expectException(CredentialsUnavailableException::class);
$this->store->getLoginCredentials(); $this->store->getLoginCredentials();
@ -276,7 +276,7 @@ class StoreTest extends TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('sess2233') ->with('sess2233')
->will($this->throwException(new PasswordlessTokenException())); ->willThrowException(new PasswordlessTokenException());
$this->session->expects($this->once()) $this->session->expects($this->once())
->method('exists') ->method('exists')

@ -39,9 +39,9 @@ class BinaryFinderTest extends TestCase {
$config $config
->method('getSystemValue') ->method('getSystemValue')
->with('binary_search_paths', $this->anything()) ->with('binary_search_paths', $this->anything())
->will($this->returnCallback(function ($key, $default) { ->willReturnCallback(function ($key, $default) {
return $default; return $default;
})); });
$finder = new BinaryFinder($this->cacheFactory, $config); $finder = new BinaryFinder($this->cacheFactory, $config);
$this->assertEquals($finder->findBinaryPath('cat'), '/usr/bin/cat'); $this->assertEquals($finder->findBinaryPath('cat'), '/usr/bin/cat');
$this->assertEquals($this->cache->get('cat'), '/usr/bin/cat'); $this->assertEquals($this->cache->get('cat'), '/usr/bin/cat');
@ -52,9 +52,9 @@ class BinaryFinderTest extends TestCase {
$config $config
->method('getSystemValue') ->method('getSystemValue')
->with('binary_search_paths', $this->anything()) ->with('binary_search_paths', $this->anything())
->will($this->returnCallback(function ($key, $default) { ->willReturnCallback(function ($key, $default) {
return $default; return $default;
})); });
$finder = new BinaryFinder($this->cacheFactory, $config); $finder = new BinaryFinder($this->cacheFactory, $config);
$this->assertFalse($finder->findBinaryPath('cata')); $this->assertFalse($finder->findBinaryPath('cata'));
$this->assertFalse($this->cache->get('cata')); $this->assertFalse($this->cache->get('cata'));

@ -150,11 +150,7 @@ class FileCacheTest extends TestCache {
->method('filemtime') ->method('filemtime')
->willReturn(100); ->willReturn(100);
$mockStorage->expects($this->atLeastOnce()) $mockStorage->expects($this->atLeastOnce())
->method('unlink') ->method('unlink')->willReturnOnConsecutiveCalls($this->throwException($testException), $this->returnValue(true));
->will($this->onConsecutiveCalls(
$this->throwException($testException),
$this->returnValue(true)
));
$this->instance->set('key1', 'value1'); $this->instance->set('key1', 'value1');
$this->instance->set('key2', 'value2'); $this->instance->set('key2', 'value2');

@ -112,11 +112,11 @@ class ResourcesRoomsUpdaterTest extends TestCase {
$backend2->method('getBackendIdentifier') $backend2->method('getBackendIdentifier')
->willReturn('backend2'); ->willReturn('backend2');
$backend2->method('listAllResources') $backend2->method('listAllResources')
->will($this->throwException(new BackendTemporarilyUnavailableException())); ->willThrowException(new BackendTemporarilyUnavailableException());
$backend2->method('getResource') $backend2->method('getResource')
->will($this->throwException(new BackendTemporarilyUnavailableException())); ->willThrowException(new BackendTemporarilyUnavailableException());
$backend2->method('getAllResources') $backend2->method('getAllResources')
->will($this->throwException(new BackendTemporarilyUnavailableException())); ->willThrowException(new BackendTemporarilyUnavailableException());
$backend3->method('getBackendIdentifier') $backend3->method('getBackendIdentifier')
->willReturn('backend3'); ->willReturn('backend3');
$backend3->method('listAllResources') $backend3->method('listAllResources')

@ -47,15 +47,15 @@ class LocalTimeProviderTest extends TestCase {
$this->l = $this->createMock(IL10N::class); $this->l = $this->createMock(IL10N::class);
$this->l->expects($this->any()) $this->l->expects($this->any())
->method('t') ->method('t')
->will($this->returnCallback(function ($text, $parameters = []) { ->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters); return vsprintf($text, $parameters);
})); });
$this->l->expects($this->any()) $this->l->expects($this->any())
->method('n') ->method('n')
->will($this->returnCallback(function ($text, $textPlural, $n, $parameters = []) { ->willReturnCallback(function ($text, $textPlural, $n, $parameters = []) {
$formatted = str_replace('%n', (string)$n, $n === 1 ? $text : $textPlural); $formatted = str_replace('%n', (string)$n, $n === 1 ? $text : $textPlural);
return vsprintf($formatted, $parameters); return vsprintf($formatted, $parameters);
})); });
$this->urlGenerator = $this->createMock(IURLGenerator::class); $this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->userManager = $this->createMock(IUserManager::class); $this->userManager = $this->createMock(IUserManager::class);
$this->timeFactory = $this->createMock(ITimeFactory::class); $this->timeFactory = $this->createMock(ITimeFactory::class);

@ -44,7 +44,7 @@ class MountPointTest extends \Test\TestCase {
$loader = $this->createMock(StorageFactory::class); $loader = $this->createMock(StorageFactory::class);
$loader->expects($this->once()) $loader->expects($this->once())
->method('wrap') ->method('wrap')
->will($this->throwException(new \Exception('Test storage init exception'))); ->willThrowException(new \Exception('Test storage init exception'));
$called = false; $called = false;
$wrapper = function ($mountPoint, $storage) use ($called): void { $wrapper = function ($mountPoint, $storage) use ($called): void {

@ -153,7 +153,7 @@ class FolderTest extends NodeTestCase {
$root->method('get') $root->method('get')
->with('/bar/foo/asd') ->with('/bar/foo/asd')
->will($this->throwException(new NotFoundException())); ->willThrowException(new NotFoundException());
$node = new Folder($root, $view, '/bar/foo'); $node = new Folder($root, $view, '/bar/foo');
$this->assertFalse($node->nodeExists('asd')); $this->assertFalse($node->nodeExists('asd'));

@ -551,7 +551,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->root->expects($this->once()) $this->root->expects($this->once())
->method('get') ->method('get')
->with('/bar/asd') ->with('/bar/asd')
->will($this->throwException(new NotFoundException())); ->willThrowException(new NotFoundException());
$node->copy('/bar/asd/foo'); $node->copy('/bar/asd/foo');
} }
@ -718,7 +718,7 @@ abstract class NodeTestCase extends \Test\TestCase {
$this->root->expects($this->once()) $this->root->expects($this->once())
->method('get') ->method('get')
->with('/bar') ->with('/bar')
->will($this->throwException(new NotFoundException())); ->willThrowException(new NotFoundException());
$node->move('/bar/asd'); $node->move('/bar/asd');
} }

@ -106,7 +106,7 @@ class AvailabilityTest extends \Test\TestCase {
->method('test'); ->method('test');
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('mkdir') ->method('mkdir')
->will($this->throwException(new StorageNotAvailableException())); ->willThrowException(new StorageNotAvailableException());
$this->storageCache->expects($this->once()) $this->storageCache->expects($this->once())
->method('setAvailability') ->method('setAvailability')
->with($this->equalTo(false)); ->with($this->equalTo(false));
@ -148,7 +148,7 @@ class AvailabilityTest extends \Test\TestCase {
->method('test'); ->method('test');
$this->storage->expects($this->once()) $this->storage->expects($this->once())
->method('mkdir') ->method('mkdir')
->will($this->throwException(new \Exception())); ->willThrowException(new \Exception());
$this->storage->expects($this->never()) $this->storage->expects($this->never())
->method('setAvailability'); ->method('setAvailability');

@ -2238,13 +2238,13 @@ class ViewTest extends \Test\TestCase {
$storage->expects($this->any()) $storage->expects($this->any())
->method('getMetaData') ->method('getMetaData')
->will($this->returnValue([ ->willReturn([
'mtime' => 1885434487, 'mtime' => 1885434487,
'etag' => '', 'etag' => '',
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'permissions' => Constants::PERMISSION_ALL, 'permissions' => Constants::PERMISSION_ALL,
'size' => 3 'size' => 3
])); ]);
$storage->expects($this->any()) $storage->expects($this->any())
->method('filemtime') ->method('filemtime')
->willReturn(123456789); ->willReturn(123456789);
@ -2433,13 +2433,13 @@ class ViewTest extends \Test\TestCase {
$storage2->expects($this->any()) $storage2->expects($this->any())
->method('getMetaData') ->method('getMetaData')
->will($this->returnValue([ ->willReturn([
'mtime' => 1885434487, 'mtime' => 1885434487,
'etag' => '', 'etag' => '',
'mimetype' => 'text/plain', 'mimetype' => 'text/plain',
'permissions' => Constants::PERMISSION_ALL, 'permissions' => Constants::PERMISSION_ALL,
'size' => 3 'size' => 3
])); ]);
$storage2->expects($this->any()) $storage2->expects($this->any())
->method('filemtime') ->method('filemtime')
->willReturn(123456789); ->willReturn(123456789);

@ -38,23 +38,14 @@ class MetaDataTest extends \Test\TestCase {
->getMock(); ->getMock();
$group->expects($this->exactly(6)) $group->expects($this->exactly(6))
->method('getGID') ->method('getGID')->willReturnOnConsecutiveCalls('admin', 'admin', 'g2', 'g2', 'g3', 'g3');
->will($this->onConsecutiveCalls(
'admin', 'admin',
'g2', 'g2',
'g3', 'g3'));
$group->expects($this->exactly(3)) $group->expects($this->exactly(3))
->method('getDisplayName') ->method('getDisplayName')->willReturnOnConsecutiveCalls('admin', 'g2', 'g3');
->will($this->onConsecutiveCalls(
'admin',
'g2',
'g3'));
$group->expects($this->exactly($countCallCount)) $group->expects($this->exactly($countCallCount))
->method('count') ->method('count')
->with('') ->with('')->willReturnOnConsecutiveCalls(2, 3, 5);
->will($this->onConsecutiveCalls(2, 3, 5));
return $group; return $group;
} }

@ -66,16 +66,16 @@ class ClientTest extends \Test\TestCase {
public function testGetProxyUriProxyHostEmptyPassword(): void { public function testGetProxyUriProxyHostEmptyPassword(): void {
$this->config $this->config
->method('getSystemValue') ->method('getSystemValue')
->will($this->returnValueMap([ ->willReturnMap([
['proxyexclude', [], []], ['proxyexclude', [], []],
])); ]);
$this->config $this->config
->method('getSystemValueString') ->method('getSystemValueString')
->will($this->returnValueMap([ ->willReturnMap([
['proxy', '', 'foo'], ['proxy', '', 'foo'],
['proxyuserpwd', '', ''], ['proxyuserpwd', '', ''],
])); ]);
$this->assertEquals([ $this->assertEquals([
'http' => 'foo', 'http' => 'foo',
@ -254,21 +254,21 @@ class ClientTest extends \Test\TestCase {
private function setUpDefaultRequestOptions(): void { private function setUpDefaultRequestOptions(): void {
$this->config $this->config
->method('getSystemValue') ->method('getSystemValue')
->will($this->returnValueMap([ ->willReturnMap([
['proxyexclude', [], []], ['proxyexclude', [], []],
])); ]);
$this->config $this->config
->method('getSystemValueString') ->method('getSystemValueString')
->will($this->returnValueMap([ ->willReturnMap([
['proxy', '', 'foo'], ['proxy', '', 'foo'],
['proxyuserpwd', '', ''], ['proxyuserpwd', '', ''],
])); ]);
$this->config $this->config
->method('getSystemValueBool') ->method('getSystemValueBool')
->will($this->returnValueMap([ ->willReturnMap([
['installed', false, true], ['installed', false, true],
['allow_local_remote_servers', false, true], ['allow_local_remote_servers', false, true],
])); ]);
$this->certificateManager $this->certificateManager
->expects($this->once()) ->expects($this->once())

@ -112,7 +112,7 @@ class CheckerTest extends TestCase {
$this->fileAccessHelper $this->fileAccessHelper
->expects($this->once()) ->expects($this->once())
->method('file_put_contents') ->method('file_put_contents')
->will($this->throwException(new \Exception('Exception message'))); ->willThrowException(new \Exception('Exception message'));
$keyBundle = file_get_contents(__DIR__ . '/../../data/integritycheck/SomeApp.crt'); $keyBundle = file_get_contents(__DIR__ . '/../../data/integritycheck/SomeApp.crt');
$rsaPrivateKey = file_get_contents(__DIR__ . '/../../data/integritycheck/SomeApp.key'); $rsaPrivateKey = file_get_contents(__DIR__ . '/../../data/integritycheck/SomeApp.key');
@ -446,7 +446,7 @@ class CheckerTest extends TestCase {
$this->fileAccessHelper $this->fileAccessHelper
->expects($this->once()) ->expects($this->once())
->method('assertDirectoryExists') ->method('assertDirectoryExists')
->will($this->throwException(new \Exception('Exception message'))); ->willThrowException(new \Exception('Exception message'));
$this->fileAccessHelper $this->fileAccessHelper
->expects($this->once()) ->expects($this->once())
->method('is_writable') ->method('is_writable')
@ -470,7 +470,7 @@ class CheckerTest extends TestCase {
$this->fileAccessHelper $this->fileAccessHelper
->expects($this->once()) ->expects($this->once())
->method('assertDirectoryExists') ->method('assertDirectoryExists')
->will($this->throwException(new \Exception('Exception message'))); ->willThrowException(new \Exception('Exception message'));
$this->fileAccessHelper $this->fileAccessHelper
->expects($this->once()) ->expects($this->once())
->method('is_writable') ->method('is_writable')

@ -38,9 +38,9 @@ class LoggerTest extends TestCase implements IWriter {
private function mockDefaultLogLevel(): void { private function mockDefaultLogLevel(): void {
$this->config->expects($this->any()) $this->config->expects($this->any())
->method('getValue') ->method('getValue')
->will(($this->returnValueMap([ ->willReturnMap([
['loglevel', ILogger::WARN, ILogger::WARN], ['loglevel', ILogger::WARN, ILogger::WARN],
]))); ]);
} }
public function testInterpolation(): void { public function testInterpolation(): void {
@ -55,10 +55,10 @@ class LoggerTest extends TestCase implements IWriter {
public function testAppCondition(): void { public function testAppCondition(): void {
$this->config->expects($this->any()) $this->config->expects($this->any())
->method('getValue') ->method('getValue')
->will(($this->returnValueMap([ ->willReturnMap([
['loglevel', ILogger::WARN, ILogger::WARN], ['loglevel', ILogger::WARN, ILogger::WARN],
['log.condition', [], ['apps' => ['files']]] ['log.condition', [], ['apps' => ['files']]]
]))); ]);
$logger = $this->logger; $logger = $this->logger;
$logger->info('Don\'t display info messages'); $logger->info('Don\'t display info messages');

@ -71,8 +71,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
$thumbnailFolder->expects($this->never()) $thumbnailFolder->expects($this->never())
->method('delete'); ->method('delete');
$this->timeFactory->method('getTime') $this->timeFactory->method('getTime')->willReturnOnConsecutiveCalls(100, 200);
->will($this->onConsecutiveCalls(100, 200));
$this->jobList->expects($this->once()) $this->jobList->expects($this->once())
->method('add') ->method('add')
@ -118,8 +117,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
$thumbnailFolder->method('getDirectoryListing') $thumbnailFolder->method('getDirectoryListing')
->willReturn([$previewFolder1]); ->willReturn([$previewFolder1]);
$this->timeFactory->method('getTime') $this->timeFactory->method('getTime')->willReturnOnConsecutiveCalls(100, 101);
->will($this->onConsecutiveCalls(100, 101));
$this->jobList->expects($this->never()) $this->jobList->expects($this->never())
->method('add'); ->method('add');
@ -213,8 +211,7 @@ class CleanPreviewsBackgroundJobTest extends TestCase {
$thumbnailFolder->method('getDirectoryListing') $thumbnailFolder->method('getDirectoryListing')
->willReturn([$previewFolder1]); ->willReturn([$previewFolder1]);
$this->timeFactory->method('getTime') $this->timeFactory->method('getTime')->willReturnOnConsecutiveCalls(100, 101);
->will($this->onConsecutiveCalls(100, 101));
$this->jobList->expects($this->never()) $this->jobList->expects($this->never())
->method('add'); ->method('add');

@ -52,10 +52,10 @@ class CleanPreviewsTest extends TestCase {
$this->userManager->expects($this->once()) $this->userManager->expects($this->once())
->method('callForSeenUsers') ->method('callForSeenUsers')
->will($this->returnCallback(function (\Closure $function) use (&$user1, $user2): void { ->willReturnCallback(function (\Closure $function) use (&$user1, $user2): void {
$function($user1); $function($user1);
$function($user2); $function($user2);
})); });
$jobListCalls = []; $jobListCalls = [];
$this->jobList->expects($this->exactly(2)) $this->jobList->expects($this->exactly(2))

@ -92,7 +92,7 @@ class RepairTest extends TestCase {
$mock = $this->createMock(TestRepairStep::class); $mock = $this->createMock(TestRepairStep::class);
$mock->expects($this->any()) $mock->expects($this->any())
->method('run') ->method('run')
->will($this->throwException(new \Exception('Exception text'))); ->willThrowException(new \Exception('Exception text'));
$mock->expects($this->any()) $mock->expects($this->any())
->method('getName') ->method('getName')
->willReturn('Exception Test'); ->willReturn('Exception Test');

@ -60,11 +60,11 @@ class ResourceLocatorTest extends \Test\TestCase {
$locator->expects($this->once()) $locator->expects($this->once())
->method('doFind') ->method('doFind')
->with('foo') ->with('foo')
->will($this->throwException(new ResourceNotFoundException('foo', 'map'))); ->willThrowException(new ResourceNotFoundException('foo', 'map'));
$locator->expects($this->once()) $locator->expects($this->once())
->method('doFindTheme') ->method('doFindTheme')
->with('foo') ->with('foo')
->will($this->throwException(new ResourceNotFoundException('foo', 'map'))); ->willThrowException(new ResourceNotFoundException('foo', 'map'));
$this->logger->expects($this->exactly(2)) $this->logger->expects($this->exactly(2))
->method('debug') ->method('debug')
->with($this->stringContains('map/foo')); ->with($this->stringContains('map/foo'));

@ -51,7 +51,7 @@ trait MountProviderTrait {
$this->mountProvider = $this->getMockBuilder('\OCP\Files\Config\IMountProvider')->getMock(); $this->mountProvider = $this->getMockBuilder('\OCP\Files\Config\IMountProvider')->getMock();
$this->mountProvider->expects($this->any()) $this->mountProvider->expects($this->any())
->method('getMountsForUser') ->method('getMountsForUser')
->will($this->returnCallback(function (IUser $user) { ->willReturnCallback(function (IUser $user) {
if (isset($this->mounts[$user->getUID()])) { if (isset($this->mounts[$user->getUID()])) {
return array_map(function ($config) { return array_map(function ($config) {
return new MountPoint($config['storage'], $config['mountPoint'], $config['arguments'], $this->storageFactory); return new MountPoint($config['storage'], $config['mountPoint'], $config['arguments'], $this->storageFactory);
@ -59,7 +59,7 @@ trait MountProviderTrait {
} else { } else {
return []; return [];
} }
})); });
Server::get(IMountProviderCollection::class)->registerProvider($this->mountProvider); Server::get(IMountProviderCollection::class)->registerProvider($this->mountProvider);
} }
} }

@ -158,7 +158,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('bar') ->with('bar')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$session->expects($this->exactly(2)) $session->expects($this->exactly(2))
->method('set') ->method('set')
->with($this->callback(function ($key) { ->with($this->callback(function ($key) {
@ -238,7 +238,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('bar') ->with('bar')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$managerMethods = get_class_methods(Manager::class); $managerMethods = get_class_methods(Manager::class);
//keep following methods intact in order to ensure hooks are working //keep following methods intact in order to ensure hooks are working
@ -298,7 +298,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('bar') ->with('bar')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$user->expects($this->never()) $user->expects($this->never())
->method('isEnabled'); ->method('isEnabled');
@ -404,7 +404,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('bar') ->with('bar')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$manager->expects($this->once()) $manager->expects($this->once())
->method('checkPasswordNoLogging') ->method('checkPasswordNoLogging')
@ -430,7 +430,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('doe') ->with('doe')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->config->expects($this->once()) $this->config->expects($this->once())
->method('getSystemValueBool') ->method('getSystemValueBool')
->with('token_auth_enforced', false) ->with('token_auth_enforced', false)
@ -466,7 +466,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('doe') ->with('doe')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->config->expects($this->once()) $this->config->expects($this->once())
->method('getSystemValueBool') ->method('getSystemValueBool')
->with('token_auth_enforced', false) ->with('token_auth_enforced', false)
@ -534,7 +534,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with('doe') ->with('doe')
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->config->expects($this->once()) $this->config->expects($this->once())
->method('getSystemValueBool') ->method('getSystemValueBool')
->with('token_auth_enforced', false) ->with('token_auth_enforced', false)
@ -788,7 +788,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('renewSessionToken') ->method('renewSessionToken')
->with($oldSessionId, $sessionId) ->with($oldSessionId, $sessionId)
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$user->expects($this->never()) $user->expects($this->never())
->method('getUID') ->method('getUID')
@ -972,7 +972,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with($password) ->with($password)
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('generateToken') ->method('generateToken')
@ -1013,7 +1013,7 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('getToken') ->method('getToken')
->with($password) ->with($password)
->will($this->throwException(new InvalidTokenException())); ->willThrowException(new InvalidTokenException());
$this->tokenProvider->expects($this->once()) $this->tokenProvider->expects($this->once())
->method('generateToken') ->method('generateToken')

@ -832,9 +832,9 @@ class UserTest extends TestCase {
['files', 'allow_unlimited_quota', '1', '1'], ['files', 'allow_unlimited_quota', '1', '1'],
]; ];
$config->method('getUserValue') $config->method('getUserValue')
->will($this->returnValueMap($userValueMap)); ->willReturnMap($userValueMap);
$config->method('getAppValue') $config->method('getAppValue')
->will($this->returnValueMap($appValueMap)); ->willReturnMap($appValueMap);
$this->assertEquals('none', $user->getQuota()); $this->assertEquals('none', $user->getQuota());
$this->assertEquals(FileInfo::SPACE_UNLIMITED, $user->getQuotaBytes()); $this->assertEquals(FileInfo::SPACE_UNLIMITED, $user->getQuotaBytes());
@ -866,9 +866,9 @@ class UserTest extends TestCase {
['files', 'default_quota', '1 GB', '1 GB'], ['files', 'default_quota', '1 GB', '1 GB'],
]; ];
$config->method('getUserValue') $config->method('getUserValue')
->will($this->returnValueMap($userValueMap)); ->willReturnMap($userValueMap);
$config->method('getAppValue') $config->method('getAppValue')
->will($this->returnValueMap($appValueMap)); ->willReturnMap($appValueMap);
$this->assertEquals('1 GB', $user->getQuota()); $this->assertEquals('1 GB', $user->getQuota());
$this->assertEquals(1024 * 1024 * 1024, $user->getQuotaBytes()); $this->assertEquals(1024 * 1024 * 1024, $user->getQuotaBytes());

Loading…
Cancel
Save