diff options
-rw-r--r-- | tests/lib/SetupTest.php | 4 | ||||
-rw-r--r-- | tests/lib/Share20/DefaultShareProviderTest.php | 16 | ||||
-rw-r--r-- | tests/lib/Share20/LegacyHooksTest.php | 25 | ||||
-rw-r--r-- | tests/lib/Share20/ShareHelperTest.php | 10 | ||||
-rw-r--r-- | tests/lib/Updater/ReleaseMetadataTest.php | 14 | ||||
-rw-r--r-- | tests/lib/Updater/VersionCheckTest.php | 2 | ||||
-rw-r--r-- | tests/lib/UpdaterTest.php | 2 | ||||
-rw-r--r-- | tests/lib/User/SessionTest.php | 52 | ||||
-rw-r--r-- | tests/lib/User/UserTest.php | 10 |
9 files changed, 73 insertions, 62 deletions
diff --git a/tests/lib/SetupTest.php b/tests/lib/SetupTest.php index b5e1b7000c3..f82060dcfa2 100644 --- a/tests/lib/SetupTest.php +++ b/tests/lib/SetupTest.php @@ -42,7 +42,7 @@ class SetupTest extends \Test\TestCase { $this->random = $this->createMock(ISecureRandom::class); $this->installer = $this->createMock(Installer::class); $this->setupClass = $this->getMockBuilder(Setup::class) - ->setMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo']) + ->onlyMethods(['class_exists', 'is_callable', 'getAvailableDbDriversForPdo']) ->setConstructorArgs([$this->config, $this->iniWrapper, $this->l10nFactory, $this->defaults, $this->logger, $this->random, $this->installer]) ->getMock(); } @@ -151,7 +151,7 @@ class SetupTest extends \Test\TestCase { $this->assertSame($webRoot, $expected); } - public function findWebRootProvider(): array { + public static function findWebRootProvider(): array { return [ 'https://www.example.com/nextcloud/' => ['https://www.example.com/nextcloud/', '/nextcloud'], 'https://www.example.com/nextcloud' => ['https://www.example.com/nextcloud', '/nextcloud'], diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php index 75a70d558c1..39560795921 100644 --- a/tests/lib/Share20/DefaultShareProviderTest.php +++ b/tests/lib/Share20/DefaultShareProviderTest.php @@ -472,7 +472,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->logger, $this->shareManager, ]) - ->setMethods(['getShareById']) + ->onlyMethods(['getShareById']) ->getMock(); $provider->delete($share); @@ -569,7 +569,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->logger, $this->shareManager, ]) - ->setMethods(['getShareById']) + ->onlyMethods(['getShareById']) ->getMock(); $provider->delete($share); @@ -968,7 +968,7 @@ class DefaultShareProviderTest extends \Test\TestCase { return $qb->getLastInsertId(); } - public function storageAndFileNameProvider() { + public static function storageAndFileNameProvider(): array { return [ // regular file on regular storage ['home::shareOwner', 'files/test.txt', 'files/test2.txt'], @@ -1281,7 +1281,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertEquals(IShare::TYPE_GROUP, $share->getShareType()); } - public function shareTypesProvider() { + public static function shareTypesProvider(): array { return [ [IShare::TYPE_USER, false], [IShare::TYPE_GROUP, false], @@ -2276,7 +2276,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertSame('/ultraNewTarget', $share->getTarget()); } - public function dataDeleteUser() { + public static function dataDeleteUser(): array { return [ [IShare::TYPE_USER, 'a', 'b', 'c', 'a', true], [IShare::TYPE_USER, 'a', 'b', 'c', 'b', false], @@ -2334,7 +2334,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertCount($rowDeleted ? 0 : 1, $data); } - public function dataDeleteUserGroup() { + public static function dataDeleteUserGroup(): array { return [ ['a', 'b', 'c', 'a', true, true], ['a', 'b', 'c', 'b', false, false], @@ -2403,7 +2403,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertCount($groupShareDeleted ? 0 : 1, $data); } - public function dataGroupDeleted() { + public static function dataGroupDeleted(): array { return [ [ [ @@ -2497,7 +2497,7 @@ class DefaultShareProviderTest extends \Test\TestCase { $this->assertCount($shouldBeDeleted ? 0 : count($ids), $data); } - public function dataUserDeletedFromGroup() { + public static function dataUserDeletedFromGroup(): array { return [ ['group1', 'user1', true], ['group1', 'user2', false], diff --git a/tests/lib/Share20/LegacyHooksTest.php b/tests/lib/Share20/LegacyHooksTest.php index 0761eed592b..4a3d3a4310b 100644 --- a/tests/lib/Share20/LegacyHooksTest.php +++ b/tests/lib/Share20/LegacyHooksTest.php @@ -23,6 +23,19 @@ use OCP\Share\IShare; use Psr\Log\LoggerInterface; use Test\TestCase; +class Dummy { + public function postShare() { + } + public function preShare() { + } + public function postFromSelf() { + } + public function post() { + } + public function pre() { + } +} + class LegacyHooksTest extends TestCase { /** @var LegacyHooks */ private $hooks; @@ -60,7 +73,7 @@ class LegacyHooksTest extends TestCase { ->setTarget('myTarget') ->setNodeCacheEntry($info); - $hookListner = $this->getMockBuilder('Dummy')->setMethods(['pre'])->getMock(); + $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['pre'])->getMock(); \OCP\Util::connectHook('OCP\Share', 'pre_unshare', $hookListner, 'pre'); $hookListnerExpectsPre = [ @@ -101,7 +114,7 @@ class LegacyHooksTest extends TestCase { ->setTarget('myTarget') ->setNodeCacheEntry($info); - $hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); + $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['post'])->getMock(); \OCP\Util::connectHook('OCP\Share', 'post_unshare', $hookListner, 'post'); $hookListnerExpectsPost = [ @@ -155,7 +168,7 @@ class LegacyHooksTest extends TestCase { ->setTarget('myTarget') ->setNodeCacheEntry($info); - $hookListner = $this->getMockBuilder('Dummy')->setMethods(['postFromSelf'])->getMock(); + $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['postFromSelf'])->getMock(); \OCP\Util::connectHook('OCP\Share', 'post_unshareFromSelf', $hookListner, 'postFromSelf'); $hookListnerExpectsPostFromSelf = [ @@ -212,7 +225,7 @@ class LegacyHooksTest extends TestCase { ->setToken('token'); - $hookListner = $this->getMockBuilder('Dummy')->setMethods(['preShare'])->getMock(); + $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['preShare'])->getMock(); \OCP\Util::connectHook('OCP\Share', 'pre_shared', $hookListner, 'preShare'); $run = true; @@ -260,7 +273,7 @@ class LegacyHooksTest extends TestCase { ->setToken('token'); - $hookListner = $this->getMockBuilder('Dummy')->setMethods(['preShare'])->getMock(); + $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['preShare'])->getMock(); \OCP\Util::connectHook('OCP\Share', 'pre_shared', $hookListner, 'preShare'); $run = true; @@ -316,7 +329,7 @@ class LegacyHooksTest extends TestCase { ->setToken('token'); - $hookListner = $this->getMockBuilder('Dummy')->setMethods(['postShare'])->getMock(); + $hookListner = $this->getMockBuilder(Dummy::class)->onlyMethods(['postShare'])->getMock(); \OCP\Util::connectHook('OCP\Share', 'post_shared', $hookListner, 'postShare'); $expected = [ diff --git a/tests/lib/Share20/ShareHelperTest.php b/tests/lib/Share20/ShareHelperTest.php index 8aaa8350ea9..9027704bb32 100644 --- a/tests/lib/Share20/ShareHelperTest.php +++ b/tests/lib/Share20/ShareHelperTest.php @@ -27,7 +27,7 @@ class ShareHelperTest extends TestCase { $this->helper = new ShareHelper($this->manager); } - public function dataGetPathsForAccessList() { + public static function dataGetPathsForAccessList(): array { return [ [[], [], false, [], [], false, [ 'users' => [], @@ -64,7 +64,7 @@ class ShareHelperTest extends TestCase { /** @var ShareHelper|\PHPUnit\Framework\MockObject\MockObject $helper */ $helper = $this->getMockBuilder(ShareHelper::class) ->setConstructorArgs([$this->manager]) - ->setMethods(['getPathsForUsers', 'getPathsForRemotes']) + ->onlyMethods(['getPathsForUsers', 'getPathsForRemotes']) ->getMock(); $helper->expects($resolveUsers ? $this->once() : $this->never()) @@ -80,7 +80,7 @@ class ShareHelperTest extends TestCase { $this->assertSame($expected, $helper->getPathsForAccessList($node)); } - public function dataGetPathsForUsers() { + public static function dataGetPathsForUsers(): array { return [ [[], [23 => 'TwentyThree', 42 => 'FortyTwo'], []], [ @@ -133,7 +133,7 @@ class ShareHelperTest extends TestCase { $this->assertEquals($expected, self::invokePrivate($this->helper, 'getPathsForUsers', [$lastNode, $users])); } - public function dataGetPathsForRemotes() { + public static function dataGetPathsForRemotes(): array { return [ [[], [23 => 'TwentyThree', 42 => 'FortyTwo'], []], [ @@ -190,7 +190,7 @@ class ShareHelperTest extends TestCase { $this->assertEquals($expected, self::invokePrivate($this->helper, 'getPathsForRemotes', [$lastNode, $remotes])); } - public function dataGetMountedPath() { + public static function dataGetMountedPath(): array { return [ ['/admin/files/foobar', '/foobar'], ['/admin/files/foo/bar', '/foo/bar'], diff --git a/tests/lib/Updater/ReleaseMetadataTest.php b/tests/lib/Updater/ReleaseMetadataTest.php index 72c6da5064d..335425b7672 100644 --- a/tests/lib/Updater/ReleaseMetadataTest.php +++ b/tests/lib/Updater/ReleaseMetadataTest.php @@ -17,9 +17,7 @@ class ReleaseMetadataTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->clientService = $this->getMockBuilder(IClientService::class) - ->disableOriginalConstructor() - ->getMock(); + $this->clientService = $this->createMock(IClientService::class); } public function testDownloadMetadata(): void { @@ -39,7 +37,7 @@ class ReleaseMetadataTest extends \Test\TestCase { $releaseMetadata = new ReleaseMetadata($this->clientService); - $this->assertSame($this->resultRequestArray(), $releaseMetadata->downloadMetadata('ouila')); + $this->assertSame(self::resultRequestArray(), $releaseMetadata->downloadMetadata('ouila')); } /** @@ -72,7 +70,7 @@ class ReleaseMetadataTest extends \Test\TestCase { /** * @return array */ - public function getMetadataUrlProvider(): array { + public static function getMetadataUrlProvider(): array { return [ [ '30.0.0', @@ -89,11 +87,11 @@ class ReleaseMetadataTest extends \Test\TestCase { ]; } - private function resultRequest(): string { - return json_encode($this->resultRequestArray()); + private static function resultRequest(): string { + return json_encode(self::resultRequestArray()); } - private function resultRequestArray(): array { + private static function resultRequestArray(): array { return [ 'migrations' => [ 'core' => [], diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php index 51d1625ea4d..4ee75c767a2 100644 --- a/tests/lib/Updater/VersionCheckTest.php +++ b/tests/lib/Updater/VersionCheckTest.php @@ -45,7 +45,7 @@ class VersionCheckTest extends \Test\TestCase { ->willReturn(false); $this->logger = $this->createMock(LoggerInterface::class); $this->updater = $this->getMockBuilder(VersionCheck::class) - ->setMethods(['getUrlContent']) + ->onlyMethods(['getUrlContent']) ->setConstructorArgs([ $this->serverVersion, $clientService, diff --git a/tests/lib/UpdaterTest.php b/tests/lib/UpdaterTest.php index 81babee7029..291aaf807e5 100644 --- a/tests/lib/UpdaterTest.php +++ b/tests/lib/UpdaterTest.php @@ -54,7 +54,7 @@ class UpdaterTest extends TestCase { /** * @return array */ - public function versionCompatibilityTestData() { + public static function versionCompatibilityTestData(): array { return [ // Upgrade with invalid version ['9.1.1.13', '11.0.2.25', ['nextcloud' => ['11.0' => true]], false], diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php index 7ed02571460..a10a0e87b81 100644 --- a/tests/lib/User/SessionTest.php +++ b/tests/lib/User/SessionTest.php @@ -96,7 +96,7 @@ class SessionTest extends \Test\TestCase { $this->logger, $this->dispatcher ]) - ->setMethods([ + ->onlyMethods([ 'setMagicInCookie', ]) ->getMock(); @@ -104,7 +104,7 @@ class SessionTest extends \Test\TestCase { \OC_User::setIncognitoMode(false); } - public function isLoggedInData() { + public static function isLoggedInData(): array { return [ [true], [false], @@ -121,7 +121,7 @@ class SessionTest extends \Test\TestCase { $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods([ + ->onlyMethods([ 'getUser' ]) ->getMock(); @@ -177,7 +177,7 @@ class SessionTest extends \Test\TestCase { //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -205,7 +205,7 @@ class SessionTest extends \Test\TestCase { $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods([ + ->onlyMethods([ 'prepareUserLogin' ]) ->getMock(); @@ -244,7 +244,7 @@ class SessionTest extends \Test\TestCase { //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -278,7 +278,7 @@ class SessionTest extends \Test\TestCase { //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -322,7 +322,7 @@ class SessionTest extends \Test\TestCase { // Keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -360,7 +360,7 @@ class SessionTest extends \Test\TestCase { // Keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -424,7 +424,7 @@ class SessionTest extends \Test\TestCase { /** @var Session $userSession */ $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser']) + ->onlyMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser']) ->getMock(); $this->tokenProvider->expects($this->once()) @@ -460,7 +460,7 @@ class SessionTest extends \Test\TestCase { /** @var Session $userSession */ $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser']) + ->onlyMethods(['login', 'supportsCookies', 'createSessionToken', 'getUser']) ->getMock(); $this->tokenProvider->expects($this->once()) @@ -486,7 +486,7 @@ class SessionTest extends \Test\TestCase { /** @var Session $userSession */ $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser']) + ->onlyMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser']) ->getMock(); $userSession->expects($this->once()) @@ -528,7 +528,7 @@ class SessionTest extends \Test\TestCase { /** @var Session $userSession */ $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods(['login', 'isTwoFactorEnforced']) + ->onlyMethods(['login', 'isTwoFactorEnforced']) ->getMock(); $this->tokenProvider->expects($this->once()) @@ -657,7 +657,7 @@ class SessionTest extends \Test\TestCase { //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -667,7 +667,7 @@ class SessionTest extends \Test\TestCase { ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() - ->setMethods(['setMagicInCookie', 'setLoginName']) + ->onlyMethods(['setMagicInCookie', 'setLoginName']) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) ->getMock(); @@ -747,7 +747,7 @@ class SessionTest extends \Test\TestCase { //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -757,7 +757,7 @@ class SessionTest extends \Test\TestCase { ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() - ->setMethods(['setMagicInCookie']) + ->onlyMethods(['setMagicInCookie']) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) ->getMock(); @@ -812,7 +812,7 @@ class SessionTest extends \Test\TestCase { //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -822,7 +822,7 @@ class SessionTest extends \Test\TestCase { ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() - ->setMethods(['setMagicInCookie']) + ->onlyMethods(['setMagicInCookie']) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) ->getMock(); @@ -865,7 +865,7 @@ class SessionTest extends \Test\TestCase { //keep following methods intact in order to ensure hooks are working $mockedManagerMethods = array_diff($managerMethods, ['__construct', 'emit', 'listen']); $manager = $this->getMockBuilder(Manager::class) - ->setMethods($mockedManagerMethods) + ->onlyMethods($mockedManagerMethods) ->setConstructorArgs([ $this->config, $this->createMock(ICacheFactory::class), @@ -875,7 +875,7 @@ class SessionTest extends \Test\TestCase { ->getMock(); $userSession = $this->getMockBuilder(Session::class) //override, otherwise tests will fail because of setcookie() - ->setMethods(['setMagicInCookie']) + ->onlyMethods(['setMagicInCookie']) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) ->getMock(); $token = 'goodToken'; @@ -925,7 +925,7 @@ class SessionTest extends \Test\TestCase { $session->set('user_id', 'foo'); $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods([ + ->onlyMethods([ 'validateSession' ]) ->getMock(); @@ -1155,7 +1155,7 @@ class SessionTest extends \Test\TestCase { $this->logger, $this->dispatcher ]) - ->setMethods([ + ->onlyMethods([ 'logClientIn', 'getUser', ]) @@ -1207,7 +1207,7 @@ class SessionTest extends \Test\TestCase { $this->logger, $this->dispatcher ]) - ->setMethods([ + ->onlyMethods([ 'logClientIn', ]) ->getMock(); @@ -1235,7 +1235,7 @@ class SessionTest extends \Test\TestCase { /** @var Session $userSession */ $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser']) + ->onlyMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser']) ->getMock(); $userSession->expects($this->once()) @@ -1281,7 +1281,7 @@ class SessionTest extends \Test\TestCase { /** @var Session $userSession */ $userSession = $this->getMockBuilder(Session::class) ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher]) - ->setMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser']) + ->onlyMethods(['isTokenPassword', 'login', 'supportsCookies', 'createSessionToken', 'getUser']) ->getMock(); $userSession->expects($this->once()) diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php index 44d28481ed5..694c1e757cb 100644 --- a/tests/lib/User/UserTest.php +++ b/tests/lib/User/UserTest.php @@ -496,7 +496,7 @@ class UserTest extends TestCase { $this->assertEquals(2, $hooksCalled); } - public function dataDeleteHooks() { + public static function dataDeleteHooks(): array { return [ [true, 2], [false, 1], @@ -632,7 +632,7 @@ class UserTest extends TestCase { ->onlyMethods(['getHome']) ->setConstructorArgs(['foo', $backend, $this->dispatcher, null, $config]) ->getMock(); - + $user->expects(self::atLeastOnce()) ->method('getHome') ->willReturn('/home/path'); @@ -650,7 +650,7 @@ class UserTest extends TestCase { $this->restoreService(\OCP\Comments\ICommentsManager::class); } - public function dataGetCloudId(): array { + public static function dataGetCloudId(): array { return [ ['https://localhost:8888/nextcloud', 'foo@localhost:8888/nextcloud'], ['http://localhost:8888/nextcloud', 'foo@http://localhost:8888/nextcloud'], @@ -964,7 +964,7 @@ class UserTest extends TestCase { null, $config, ]) - ->setMethods(['isEnabled', 'triggerChange']) + ->onlyMethods(['isEnabled', 'triggerChange']) ->getMock(); $user->expects($this->once()) @@ -998,7 +998,7 @@ class UserTest extends TestCase { null, $config, ]) - ->setMethods(['isEnabled', 'triggerChange']) + ->onlyMethods(['isEnabled', 'triggerChange']) ->getMock(); $user->expects($this->once()) |