summaryrefslogtreecommitdiffstats
path: root/tests/lib/User
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-25 22:21:27 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-25 22:21:27 +0100
commit2ee65f177e4f7e09ad2287f14d564e7068d322fb (patch)
tree39075e87ea7927e20e8956824cb7c49bf626b178 /tests/lib/User
parent3cf321fdfc4235a87015a9af2f59c63220016c65 (diff)
downloadnextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.tar.gz
nextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.zip
Use the shorter phpunit syntax for mocked return values
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/User')
-rw-r--r--tests/lib/User/ManagerTest.php74
-rw-r--r--tests/lib/User/SessionTest.php160
-rw-r--r--tests/lib/User/UserTest.php78
3 files changed, 156 insertions, 156 deletions
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index 40197101fd6..1dc0182a960 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -60,7 +60,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
@@ -76,7 +76,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false));
+ ->willReturn(false);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
@@ -98,7 +98,7 @@ class ManagerTest extends TestCase {
$backend1->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false));
+ ->willReturn(false);
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
@@ -107,7 +107,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend1);
@@ -124,7 +124,7 @@ class ManagerTest extends TestCase {
$backend1->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
@@ -148,17 +148,17 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('checkPassword')
->with($this->equalTo('foo'), $this->equalTo('bar'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\USER\BACKEND::CHECK_PASSWORD) {
return true;
} else {
return false;
}
- }));
+ });
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
@@ -177,7 +177,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
@@ -193,7 +193,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->never())
->method('loginName2UserName');
@@ -211,7 +211,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false));
+ ->willReturn(false);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
@@ -227,7 +227,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('bLeNdEr'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->never())
->method('loginName2UserName');
@@ -245,7 +245,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('getUsers')
->with($this->equalTo('fo'))
- ->will($this->returnValue(array('foo', 'afoo', 'Afoo1', 'Bfoo')));
+ ->willReturn(array('foo', 'afoo', 'Afoo1', 'Bfoo'));
$backend->expects($this->never())
->method('loginName2UserName');
@@ -268,7 +268,7 @@ class ManagerTest extends TestCase {
$backend1->expects($this->once())
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
- ->will($this->returnValue(array('foo1', 'foo2')));
+ ->willReturn(array('foo1', 'foo2'));
$backend1->expects($this->never())
->method('loginName2UserName');
@@ -279,7 +279,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->once())
->method('getUsers')
->with($this->equalTo('fo'), $this->equalTo(3), $this->equalTo(1))
- ->will($this->returnValue(array('foo3')));
+ ->willReturn(array('foo3'));
$backend2->expects($this->never())
->method('loginName2UserName');
@@ -351,7 +351,7 @@ class ManagerTest extends TestCase {
$backend = $this->createMock(\Test\Util\User\Dummy::class);
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->once())
->method('createUser')
@@ -360,7 +360,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false));
+ ->willReturn(false);
$backend->expects($this->never())
->method('loginName2UserName');
@@ -381,7 +381,7 @@ class ManagerTest extends TestCase {
$backend = $this->createMock(\Test\Util\User\Dummy::class);
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->never())
->method('createUser');
@@ -389,7 +389,7 @@ class ManagerTest extends TestCase {
$backend->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
@@ -404,7 +404,7 @@ class ManagerTest extends TestCase {
$backend = $this->createMock(\Test\Util\User\Dummy::class);
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$backend->expects($this->never())
->method('createUser');
@@ -453,7 +453,7 @@ class ManagerTest extends TestCase {
$backend1 = $this->createMock(\Test\Util\User\Dummy::class);
$backend1->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend1->expects($this->never())
->method('createUser');
@@ -461,7 +461,7 @@ class ManagerTest extends TestCase {
$backend1->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false));
+ ->willReturn(false);
/**
* @var \Test\Util\User\Dummy | \PHPUnit_Framework_MockObject_MockObject $backend2
@@ -469,7 +469,7 @@ class ManagerTest extends TestCase {
$backend2 = $this->createMock(\Test\Util\User\Dummy::class);
$backend2->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend2->expects($this->never())
->method('createUser');
@@ -477,7 +477,7 @@ class ManagerTest extends TestCase {
$backend2->expects($this->once())
->method('userExists')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend1);
@@ -501,16 +501,16 @@ class ManagerTest extends TestCase {
$backend = $this->createMock(\Test\Util\User\Dummy::class);
$backend->expects($this->once())
->method('countUsers')
- ->will($this->returnValue(7));
+ ->willReturn(7);
$backend->expects($this->once())
->method('implementsActions')
->with(\OC\USER\BACKEND::COUNT_USERS)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->once())
->method('getBackendName')
- ->will($this->returnValue('Mock_Test_Util_User_Dummy'));
+ ->willReturn('Mock_Test_Util_User_Dummy');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
@@ -530,28 +530,28 @@ class ManagerTest extends TestCase {
$backend1 = $this->createMock(\Test\Util\User\Dummy::class);
$backend1->expects($this->once())
->method('countUsers')
- ->will($this->returnValue(7));
+ ->willReturn(7);
$backend1->expects($this->once())
->method('implementsActions')
->with(\OC\USER\BACKEND::COUNT_USERS)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend1->expects($this->once())
->method('getBackendName')
- ->will($this->returnValue('Mock_Test_Util_User_Dummy'));
+ ->willReturn('Mock_Test_Util_User_Dummy');
$backend2 = $this->createMock(\Test\Util\User\Dummy::class);
$backend2->expects($this->once())
->method('countUsers')
- ->will($this->returnValue(16));
+ ->willReturn(16);
$backend2->expects($this->once())
->method('implementsActions')
->with(\OC\USER\BACKEND::COUNT_USERS)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend2->expects($this->once())
->method('getBackendName')
- ->will($this->returnValue('Mock_Test_Util_User_Dummy'));
+ ->willReturn('Mock_Test_Util_User_Dummy');
$manager = new \OC\User\Manager($this->config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend1);
@@ -672,21 +672,21 @@ class ManagerTest extends TestCase {
->expects($this->at(0))
->method('getUsersForUserValueCaseInsensitive')
->with('settings', 'email', 'test@example.com')
- ->will($this->returnValue(['uid1', 'uid99', 'uid2']));
+ ->willReturn(['uid1', 'uid99', 'uid2']);
$backend = $this->createMock(\Test\Util\User\Dummy::class);
$backend->expects($this->at(0))
->method('userExists')
->with($this->equalTo('uid1'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->at(1))
->method('userExists')
->with($this->equalTo('uid99'))
- ->will($this->returnValue(false));
+ ->willReturn(false);
$backend->expects($this->at(2))
->method('userExists')
->with($this->equalTo('uid2'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$manager = new \OC\User\Manager($config, $this->oldDispatcher, $this->eventDispatcher);
$manager->registerBackend($backend);
diff --git a/tests/lib/User/SessionTest.php b/tests/lib/User/SessionTest.php
index e7df7578c7d..c96a07eb9af 100644
--- a/tests/lib/User/SessionTest.php
+++ b/tests/lib/User/SessionTest.php
@@ -67,7 +67,7 @@ class SessionTest extends \Test\TestCase {
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->timeFactory->expects($this->any())
->method('getTime')
- ->will($this->returnValue(10000));
+ ->willReturn(10000);
$this->tokenProvider = $this->createMock(IProvider::class);
$this->config = $this->createMock(IConfig::class);
$this->throttler = $this->createMock(Throttler::class);
@@ -105,12 +105,12 @@ class SessionTest extends \Test\TestCase {
$expectedUser = $this->createMock(IUser::class);
$expectedUser->expects($this->any())
->method('getUID')
- ->will($this->returnValue('user123'));
+ ->willReturn('user123');
$session = $this->getMockBuilder(Memory::class)->setConstructorArgs([''])->getMock();
$session->expects($this->at(0))
->method('get')
->with('user_id')
- ->will($this->returnValue($expectedUser->getUID()));
+ ->willReturn($expectedUser->getUID());
$sessionId = 'abcdef12345';
$manager = $this->getMockBuilder('\OC\User\Manager')
@@ -119,25 +119,25 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->at(1))
->method('get')
->with('app_password')
- ->will($this->returnValue(null)); // No password set -> browser session
+ ->willReturn(null); // No password set -> browser session
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$this->tokenProvider->expects($this->once())
->method('getToken')
->with($sessionId)
- ->will($this->returnValue($token));
+ ->willReturn($token);
$this->tokenProvider->expects($this->once())
->method('getPassword')
->with($token, $sessionId)
- ->will($this->returnValue('passme'));
+ ->willReturn('passme');
$manager->expects($this->once())
->method('checkPassword')
->with('User123', 'passme')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$expectedUser->expects($this->once())
->method('isEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->tokenProvider->expects($this->once())
->method('updateTokenActivity')
@@ -146,7 +146,7 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with($expectedUser->getUID())
- ->will($this->returnValue($expectedUser));
+ ->willReturn($expectedUser);
$userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher);
$user = $userSession->getUser();
@@ -178,7 +178,7 @@ class SessionTest extends \Test\TestCase {
$user = new User('sepp', null, $this->createMock(EventDispatcherInterface::class));
$userSession->expects($this->once())
->method('getUser')
- ->will($this->returnValue($isLoggedIn ? $user : null));
+ ->willReturn($isLoggedIn ? $user : null);
$this->assertEquals($isLoggedIn, $userSession->isLoggedIn());
}
@@ -195,7 +195,7 @@ class SessionTest extends \Test\TestCase {
$user = $this->createMock(IUser::class);
$user->expects($this->once())
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher);
$userSession->setUser($user);
@@ -240,17 +240,17 @@ class SessionTest extends \Test\TestCase {
$user = $this->createMock(IUser::class);
$user->expects($this->any())
->method('isEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$user->expects($this->any())
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$user->expects($this->once())
->method('updateLastLoginTimestamp');
$manager->expects($this->once())
->method('checkPasswordNoLogging')
->with('foo', 'bar')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([$manager, $session, $this->timeFactory, $this->tokenProvider, $this->config, $this->random, $this->lockdownManager, $this->logger, $this->dispatcher])
@@ -304,14 +304,14 @@ class SessionTest extends \Test\TestCase {
$user = $this->createMock(IUser::class);
$user->expects($this->any())
->method('isEnabled')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user->expects($this->never())
->method('updateLastLoginTimestamp');
$manager->expects($this->once())
->method('checkPasswordNoLogging')
->with('foo', 'bar')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->dispatcher->expects($this->never())
->method('dispatch');
@@ -355,7 +355,7 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('checkPasswordNoLogging')
->with('foo', 'bar')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->dispatcher->expects($this->never())
->method('dispatch');
@@ -380,7 +380,7 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('checkPasswordNoLogging')
->with('foo', 'bar')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$userSession->login('foo', 'bar');
}
@@ -404,12 +404,12 @@ class SessionTest extends \Test\TestCase {
$this->tokenProvider->expects($this->once())
->method('getToken')
->with('bar')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$manager->expects($this->once())
->method('checkPasswordNoLogging')
->with('foo', 'bar')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$userSession->login('foo', 'bar');
}
@@ -435,7 +435,7 @@ class SessionTest extends \Test\TestCase {
$this->config->expects($this->once())
->method('getSystemValue')
->with('token_auth_enforced', false)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$request
->expects($this->any())
->method('getRemoteAddress')
@@ -471,7 +471,7 @@ class SessionTest extends \Test\TestCase {
$this->config->expects($this->once())
->method('getSystemValue')
->with('token_auth_enforced', false)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$manager->method('getByEmail')
->with('unexist')
->willReturn([]);
@@ -492,11 +492,11 @@ class SessionTest extends \Test\TestCase {
$userSession->expects($this->once())
->method('isTokenPassword')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$userSession->expects($this->once())
->method('login')
->with('john', 'I-AM-AN-APP-PASSWORD')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$session->expects($this->once())
->method('set')
@@ -539,12 +539,12 @@ class SessionTest extends \Test\TestCase {
$this->config->expects($this->once())
->method('getSystemValue')
->with('token_auth_enforced', false)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$userSession->expects($this->once())
->method('isTwoFactorEnforced')
->with('john')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$request
->expects($this->any())
@@ -592,18 +592,18 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->config->expects($this->once())
->method('getUserKeys')
->with('foo', 'login_token')
- ->will($this->returnValue([$token]));
+ ->willReturn([$token]);
$this->config->expects($this->once())
->method('deleteUserValue')
->with('foo', 'login_token', $token);
$this->random->expects($this->once())
->method('generate')
->with(32)
- ->will($this->returnValue('abcdefg123456'));
+ ->willReturn('abcdefg123456');
$this->config->expects($this->once())
->method('setUserValue')
->with('foo', 'login_token', 'abcdefg123456', 10000);
@@ -617,7 +617,7 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$this->tokenProvider->expects($this->once())
->method('renewSessionToken')
->with($oldSessionId, $sessionId)
@@ -628,7 +628,7 @@ class SessionTest extends \Test\TestCase {
$user->expects($this->any())
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$userSession->expects($this->once())
->method('setMagicInCookie');
$user->expects($this->once())
@@ -636,11 +636,11 @@ class SessionTest extends \Test\TestCase {
$setUID = false;
$session
->method('set')
- ->will($this->returnCallback(function ($k, $v) use (&$setUID) {
+ ->willReturnCallback(function ($k, $v) use (&$setUID) {
if ($k === 'user_id' && $v === 'foo') {
$setUID = true;
}
- }));
+ });
$userSession->expects($this->once())
->method('setLoginName')
->willReturn('foobar');
@@ -681,11 +681,11 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->config->expects($this->once())
->method('getUserKeys')
->with('foo', 'login_token')
- ->will($this->returnValue([$token]));
+ ->willReturn([$token]);
$this->config->expects($this->once())
->method('deleteUserValue')
->with('foo', 'login_token', $token);
@@ -694,7 +694,7 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$this->tokenProvider->expects($this->once())
->method('renewSessionToken')
->with($oldSessionId, $sessionId)
@@ -702,7 +702,7 @@ class SessionTest extends \Test\TestCase {
$user->expects($this->never())
->method('getUID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$userSession->expects($this->never())
->method('setMagicInCookie');
$user->expects($this->never())
@@ -744,11 +744,11 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->config->expects($this->once())
->method('getUserKeys')
->with('foo', 'login_token')
- ->will($this->returnValue(['anothertoken']));
+ ->willReturn(['anothertoken']);
$this->config->expects($this->never())
->method('deleteUserValue')
->with('foo', 'login_token', $token);
@@ -794,11 +794,11 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$this->config->expects($this->never())
->method('getUserKeys')
->with('foo', 'login_token')
- ->will($this->returnValue(['anothertoken']));
+ ->willReturn(['anothertoken']);
$this->tokenProvider->expects($this->never())
->method('renewSessionToken');
@@ -825,9 +825,9 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->any())
->method('get')
- ->will($this->returnCallback(function ($uid) use ($users) {
+ ->willReturnCallback(function ($uid) use ($users) {
return $users[$uid];
- }));
+ });
$session = new Memory('');
$session->set('user_id', 'foo');
@@ -873,10 +873,10 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with($uid)
- ->will($this->returnValue($user));
+ ->willReturn($user);
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$this->tokenProvider->expects($this->once())
->method('getToken')
->with($password)
@@ -914,10 +914,10 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with($uid)
- ->will($this->returnValue($user));
+ ->willReturn($user);
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$this->tokenProvider->expects($this->once())
->method('getToken')
->with($password)
@@ -959,18 +959,18 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with($uid)
- ->will($this->returnValue($user));
+ ->willReturn($user);
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$this->tokenProvider->expects($this->once())
->method('getToken')
->with($password)
- ->will($this->returnValue($token));
+ ->willReturn($token);
$this->tokenProvider->expects($this->once())
->method('getPassword')
->with($token, $password)
- ->will($this->returnValue($realPassword));
+ ->willReturn($realPassword);
$this->tokenProvider->expects($this->once())
->method('generateToken')
@@ -994,7 +994,7 @@ class SessionTest extends \Test\TestCase {
$manager->expects($this->once())
->method('get')
->with($uid)
- ->will($this->returnValue(null));
+ ->willReturn(null);
$this->assertFalse($userSession->createSessionToken($request, $uid, $loginName, $password));
}
@@ -1021,18 +1021,18 @@ class SessionTest extends \Test\TestCase {
$request->expects($this->once())
->method('getHeader')
->with('Authorization')
- ->will($this->returnValue('Bearer xxxxx'));
+ ->willReturn('Bearer xxxxx');
$this->tokenProvider->expects($this->once())
->method('getToken')
->with('xxxxx')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$manager->expects($this->once())
->method('get')
->with('fritz0')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$user->expects($this->once())
->method('isEnabled')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$userSession->tryTokenLogin($request);
}
@@ -1055,23 +1055,23 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->once())
->method('get')
->with('app_password')
- ->will($this->returnValue('APP-PASSWORD'));
+ ->willReturn('APP-PASSWORD');
$tokenProvider->expects($this->once())
->method('getToken')
->with('APP-PASSWORD')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$timeFactory->expects($this->once())
->method('getTime')
- ->will($this->returnValue(1000)); // more than 5min since last check
+ ->willReturn(1000); // more than 5min since last check
$tokenProvider->expects($this->once())
->method('getPassword')
->with($token, 'APP-PASSWORD')
- ->will($this->returnValue('123456'));
+ ->willReturn('123456');
$userManager->expects($this->never())
->method('checkPassword');
$user->expects($this->once())
->method('isEnabled')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$tokenProvider->expects($this->once())
->method('invalidateToken')
->with('APP-PASSWORD');
@@ -1099,14 +1099,14 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->once())
->method('get')
->with('app_password')
- ->will($this->returnValue('APP-PASSWORD'));
+ ->willReturn('APP-PASSWORD');
$tokenProvider->expects($this->once())
->method('getToken')
->with('APP-PASSWORD')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$timeFactory->expects($this->once())
->method('getTime')
- ->will($this->returnValue(1000)); // more than 5min since last check
+ ->willReturn(1000); // more than 5min since last check
$tokenProvider->expects($this->once())
->method('getPassword')
->with($token, 'APP-PASSWORD')
@@ -1135,25 +1135,25 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->once())
->method('get')
->with('app_password')
- ->will($this->returnValue('APP-PASSWORD'));
+ ->willReturn('APP-PASSWORD');
$tokenProvider->expects($this->once())
->method('getToken')
->with('APP-PASSWORD')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$timeFactory->expects($this->once())
->method('getTime')
- ->will($this->returnValue(1000)); // more than 5min since last check
+ ->willReturn(1000); // more than 5min since last check
$tokenProvider->expects($this->once())
->method('getPassword')
->with($token, 'APP-PASSWORD')
- ->will($this->returnValue('123456'));
+ ->willReturn('123456');
$userManager->expects($this->once())
->method('checkPassword')
->with('susan', '123456')
->willReturn(false);
$user->expects($this->once())
->method('isEnabled')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$tokenProvider->expects($this->never())
->method('invalidateToken');
$tokenProvider->expects($this->once())
@@ -1179,11 +1179,11 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$tokenProvider->expects($this->once())
->method('getToken')
->with($sessionId)
- ->will($this->returnValue($token));
+ ->willReturn($token);
$tokenProvider->expects($this->once())
->method('setPassword')
->with($token, $sessionId, $password);
@@ -1218,11 +1218,11 @@ class SessionTest extends \Test\TestCase {
$session->expects($this->once())
->method('getId')
- ->will($this->returnValue($sessionId));
+ ->willReturn($sessionId);
$tokenProvider->expects($this->once())
->method('getToken')
->with($sessionId)
- ->will($this->returnValue($token));
+ ->willReturn($token);
$tokenProvider->expects($this->once())
->method('setPassword')
->with($token, $sessionId, $password)
@@ -1254,7 +1254,7 @@ class SessionTest extends \Test\TestCase {
$mapper->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$mapper->expects($this->once())
->method('update');
$request
@@ -1273,7 +1273,7 @@ class SessionTest extends \Test\TestCase {
$this->timeFactory
->expects($this->any())
->method('getTime')
- ->will($this->returnValue(100));
+ ->willReturn(100);
$manager->method('getByEmail')
->with('john')
@@ -1308,7 +1308,7 @@ class SessionTest extends \Test\TestCase {
$mapper->expects($this->any())
->method('getToken')
- ->will($this->returnValue($token));
+ ->willReturn($token);
$mapper->expects($this->never())
->method('update');
$request
@@ -1327,7 +1327,7 @@ class SessionTest extends \Test\TestCase {
$this->timeFactory
->expects($this->any())
->method('getTime')
- ->will($this->returnValue(100));
+ ->willReturn(100);
$manager->method('getByEmail')
->with('john')
@@ -1375,7 +1375,7 @@ class SessionTest extends \Test\TestCase {
$this->session
->method('set')
- ->will($this->returnCallback(function($k, $v) use (&$davAuthenticatedSet, &$lastPasswordConfirmSet) {
+ ->willReturnCallback(function($k, $v) use (&$davAuthenticatedSet, &$lastPasswordConfirmSet) {
switch ($k) {
case Auth::DAV_AUTHENTICATED:
$davAuthenticatedSet = $v;
@@ -1386,7 +1386,7 @@ class SessionTest extends \Test\TestCase {
default:
throw new \Exception();
}
- }));
+ });
$userSession = $this->getMockBuilder(Session::class)
->setConstructorArgs([
diff --git a/tests/lib/User/UserTest.php b/tests/lib/User/UserTest.php
index 8431f14f8a2..4e527addc6e 100644
--- a/tests/lib/User/UserTest.php
+++ b/tests/lib/User/UserTest.php
@@ -47,12 +47,12 @@ class UserTest extends TestCase {
$backend->expects($this->once())
->method('getDisplayName')
->with($this->equalTo('foo'))
- ->will($this->returnValue('Foo'));
+ ->willReturn('Foo');
$backend->expects($this->any())
->method('implementsActions')
->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$user = new User('foo', $backend, $this->dispatcher);
$this->assertEquals('Foo', $user->getDisplayName());
@@ -69,12 +69,12 @@ class UserTest extends TestCase {
$backend->expects($this->once())
->method('getDisplayName')
->with($this->equalTo('foo'))
- ->will($this->returnValue(' '));
+ ->willReturn(' ');
$backend->expects($this->any())
->method('implementsActions')
->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$user = new User('foo', $backend, $this->dispatcher);
$this->assertEquals('foo', $user->getDisplayName());
@@ -91,7 +91,7 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
->with($this->equalTo(\OC\User\Backend::GET_DISPLAYNAME))
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user = new User('foo', $backend, $this->dispatcher);
$this->assertEquals('foo', $user->getDisplayName());
@@ -108,13 +108,13 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::SET_PASSWORD) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher);
$this->assertTrue($user->setPassword('bar',''));
@@ -130,7 +130,7 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user = new User('foo', $backend, $this->dispatcher);
$this->assertFalse($user->setPassword('bar',''));
@@ -144,17 +144,17 @@ class UserTest extends TestCase {
$backend->expects($this->once())
->method('canChangeAvatar')
->with($this->equalTo('foo'))
- ->will($this->returnValue(true));
+ ->willReturn(true);
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::PROVIDE_AVATAR) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher);
$this->assertTrue($user->canChangeAvatar());
@@ -168,17 +168,17 @@ class UserTest extends TestCase {
$backend->expects($this->once())
->method('canChangeAvatar')
->with($this->equalTo('foo'))
- ->will($this->returnValue(false));
+ ->willReturn(false);
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::PROVIDE_AVATAR) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher);
$this->assertFalse($user->canChangeAvatar());
@@ -221,13 +221,13 @@ class UserTest extends TestCase {
$backend->expects($this->at(0))
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::GET_HOME) {
return true;
} else {
return false;
}
- }));
+ });
// important: getHome MUST be called before deleteUser because
// once the user is deleted, getHome implementations might not
@@ -235,7 +235,7 @@ class UserTest extends TestCase {
$backend->expects($this->at(1))
->method('getHome')
->with($this->equalTo('foo'))
- ->will($this->returnValue('/home/foo'));
+ ->willReturn('/home/foo');
$backend->expects($this->at(2))
->method('deleteUser')
@@ -253,17 +253,17 @@ class UserTest extends TestCase {
$backend->expects($this->once())
->method('getHome')
->with($this->equalTo('foo'))
- ->will($this->returnValue('/home/foo'));
+ ->willReturn('/home/foo');
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::GET_HOME) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher);
$this->assertEquals('/home/foo', $user->getHome());
@@ -286,18 +286,18 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$allConfig = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$allConfig->expects($this->any())
->method('getUserValue')
- ->will($this->returnValue(true));
+ ->willReturn(true);
$allConfig->expects($this->any())
->method('getSystemValue')
->with($this->equalTo('datadirectory'))
- ->will($this->returnValue('arbitrary/path'));
+ ->willReturn('arbitrary/path');
$user = new User('foo', $backend, $this->dispatcher, null, $allConfig);
$this->assertEquals('arbitrary/path/foo', $user->getHome());
@@ -311,13 +311,13 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::SET_PASSWORD) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher);
$this->assertTrue($user->canChangePassword());
@@ -331,7 +331,7 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user = new User('foo', $backend, $this->dispatcher);
$this->assertFalse($user->canChangePassword());
@@ -345,13 +345,13 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::SET_DISPLAYNAME) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher);
$this->assertTrue($user->canChangeDisplayName());
@@ -365,7 +365,7 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$user = new User('foo', $backend, $this->dispatcher);
$this->assertFalse($user->canChangeDisplayName());
@@ -379,13 +379,13 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::SET_DISPLAYNAME) {
return true;
} else {
return false;
}
- }));
+ });
$backend->expects($this->once())
->method('setDisplayName')
@@ -408,13 +408,13 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::SET_DISPLAYNAME) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher);
$this->assertFalse($user->setDisplayName(' '));
@@ -466,13 +466,13 @@ class UserTest extends TestCase {
$backend->expects($this->any())
->method('implementsActions')
- ->will($this->returnCallback(function ($actions) {
+ ->willReturnCallback(function ($actions) {
if ($actions === \OC\User\Backend::SET_PASSWORD) {
return true;
} else {
return false;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher, $emitter);
@@ -751,13 +751,13 @@ class UserTest extends TestCase {
$config = $this->createMock(IConfig::class);
$config->method('getUserValue')
- ->will($this->returnCallback(function ($uid, $app, $key, $default) {
+ ->willReturnCallback(function ($uid, $app, $key, $default) {
if ($uid === 'foo' && $app === 'login' && $key === 'lastLogin') {
return 42;
} else {
return $default;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher, null, $config);
$this->assertSame(42, $user->getLastLogin());
@@ -861,13 +861,13 @@ class UserTest extends TestCase {
$config = $this->createMock(IConfig::class);
$config->method('getUserValue')
- ->will($this->returnCallback(function ($uid, $app, $key, $default) {
+ ->willReturnCallback(function ($uid, $app, $key, $default) {
if ($uid === 'foo' && $app === 'settings' && $key === 'email') {
return 'foo@bar.com';
} else {
return $default;
}
- }));
+ });
$user = new User('foo', $backend, $this->dispatcher, null, $config);
$this->assertSame('foo@bar.com', $user->getEMailAddress());