summaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes
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 /apps/twofactor_backupcodes
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 'apps/twofactor_backupcodes')
-rw-r--r--apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php4
-rw-r--r--apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php2
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php4
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php6
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php12
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php8
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php22
7 files changed, 29 insertions, 29 deletions
diff --git a/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php b/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php
index 136a734aa81..89cd88e05e3 100644
--- a/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php
+++ b/apps/twofactor_backupcodes/tests/Db/BackupCodeMapperTest.php
@@ -84,7 +84,7 @@ class BackupCodeMapperTest extends TestCase {
$user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->once())
->method('getUID')
- ->will($this->returnValue($this->testUID));
+ ->willReturn($this->testUID);
$dbCodes = $this->mapper->getBackupCodes($user);
@@ -101,7 +101,7 @@ class BackupCodeMapperTest extends TestCase {
$user = $this->getMockBuilder(IUser::class)->getMock();
$user->expects($this->any())
->method('getUID')
- ->will($this->returnValue($this->testUID));
+ ->willReturn($this->testUID);
$this->mapper->insert($code);
diff --git a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
index 342ab35b0ea..8cd20df85a7 100644
--- a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
+++ b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
@@ -59,7 +59,7 @@ class BackupCodeStorageTest extends TestCase {
$user = $this->getMockBuilder(\OCP\IUser::class)->getMock();
$user->expects($this->any())
->method('getUID')
- ->will($this->returnValue($this->testUID));
+ ->willReturn($this->testUID);
$this->notificationManager->expects($this->once())
->method('markProcessed')
diff --git a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
index bd0062e826b..141e6d13202 100644
--- a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
@@ -68,9 +68,9 @@ class CheckBackupCodeTest extends TestCase {
$this->user = $this->createMock(IUser::class);
$this->userManager->method('callForSeenUsers')
- ->will($this->returnCallback(function(\Closure $e) {
+ ->willReturnCallback(function(\Closure $e) {
$e($this->user);
- }));
+ });
$this->checkBackupCodes = new CheckBackupCodes(
$this->createMock(ITimeFactory::class),
diff --git a/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php b/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php
index 0f4b12eae5f..95d94e4fc0d 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Controller/SettingsControllerTest.php
@@ -65,15 +65,15 @@ class SettingsControllerTest extends TestCase {
$codes = ['a', 'b'];
$this->userSession->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->storage->expects($this->once())
->method('createCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$this->storage->expects($this->once())
->method('getBackupCodesState')
->with($user)
- ->will($this->returnValue('state'));
+ ->willReturn('state');
$expected = [
'codes' => $codes,
diff --git a/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php b/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php
index 5a5b3a6d29a..2aec2e72d94 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Listener/ActivityPublisherTest.php
@@ -73,26 +73,26 @@ class ActivityPublisherTest extends TestCase {
$activityEvent = $this->createMock(IEvent::class);
$this->activityManager->expects($this->once())
->method('generateEvent')
- ->will($this->returnValue($activityEvent));
+ ->willReturn($activityEvent);
$activityEvent->expects($this->once())
->method('setApp')
->with('twofactor_backupcodes')
- ->will($this->returnSelf());
+ ->willReturnSelf();
$activityEvent->expects($this->once())
->method('setType')
->with('security')
- ->will($this->returnSelf());
+ ->willReturnSelf();
$activityEvent->expects($this->once())
->method('setAuthor')
->with('fritz')
- ->will($this->returnSelf());
+ ->willReturnSelf();
$activityEvent->expects($this->once())
->method('setAffectedUser')
->with('fritz')
- ->will($this->returnSelf());
+ ->willReturnSelf();
$this->activityManager->expects($this->once())
->method('publish')
- ->will($this->returnValue($activityEvent));
+ ->willReturn($activityEvent);
$this->listener->handle($event);
}
diff --git a/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php b/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php
index 194e9dc6e05..2ade2046e75 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Provider/BackupCodesProviderTest.php
@@ -74,7 +74,7 @@ class BackupCodesProviderTest extends TestCase {
$this->l10n->expects($this->once())
->method('t')
->with('Backup code')
- ->will($this->returnValue('l10n backup code'));
+ ->willReturn('l10n backup code');
$this->assertSame('l10n backup code', $this->provider->getDisplayName());
}
@@ -82,7 +82,7 @@ class BackupCodesProviderTest extends TestCase {
$this->l10n->expects($this->once())
->method('t')
->with('Use backup code')
- ->will($this->returnValue('l10n use backup code'));
+ ->willReturn('l10n use backup code');
$this->assertSame('l10n use backup code', $this->provider->getDescription());
}
@@ -100,7 +100,7 @@ class BackupCodesProviderTest extends TestCase {
$this->storage->expects($this->once())
->method('validateCode')
->with($user, $challenge)
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->assertFalse($this->provider->verifyChallenge($user, $challenge));
}
@@ -111,7 +111,7 @@ class BackupCodesProviderTest extends TestCase {
$this->storage->expects($this->once())
->method('hasBackupCodes')
->with($user)
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->assertTrue($this->provider->isTwoFactorAuthEnabledForUser($user));
}
diff --git a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
index a2bd743c17c..ab895f4d854 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
@@ -70,11 +70,11 @@ class BackupCodeStorageTest extends TestCase {
$this->random->expects($this->exactly($number))
->method('generate')
->with(16, ISecureRandom::CHAR_HUMAN_READABLE)
- ->will($this->returnValue('CODEABCDEF'));
+ ->willReturn('CODEABCDEF');
$this->hasher->expects($this->exactly($number))
->method('hash')
->with('CODEABCDEF')
- ->will($this->returnValue('HASHEDCODE'));
+ ->willReturn('HASHEDCODE');
$row = new BackupCode();
$row->setUserId('fritz');
$row->setCode('HASHEDCODE');
@@ -106,7 +106,7 @@ class BackupCodeStorageTest extends TestCase {
$this->mapper->expects($this->once())
->method('getBackupCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$this->assertTrue($this->storage->hasBackupCodes($user));
}
@@ -118,7 +118,7 @@ class BackupCodeStorageTest extends TestCase {
$this->mapper->expects($this->once())
->method('getBackupCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$this->assertFalse($this->storage->hasBackupCodes($user));
}
@@ -138,7 +138,7 @@ class BackupCodeStorageTest extends TestCase {
$this->mapper->expects($this->once())
->method('getBackupCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$expected = [
'enabled' => true,
@@ -156,7 +156,7 @@ class BackupCodeStorageTest extends TestCase {
$this->mapper->expects($this->once())
->method('getBackupCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$expected = [
'enabled' => false,
@@ -178,11 +178,11 @@ class BackupCodeStorageTest extends TestCase {
$this->mapper->expects($this->once())
->method('getBackupCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$this->hasher->expects($this->once())
->method('verify')
->with('CHALLENGE', 'HASHEDVALUE', $this->anything())
- ->will($this->returnValue(true));
+ ->willReturn(true);
$this->mapper->expects($this->once())
->method('update')
->with($code);
@@ -204,7 +204,7 @@ class BackupCodeStorageTest extends TestCase {
$this->mapper->expects($this->once())
->method('getBackupCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$this->hasher->expects($this->never())
->method('verify');
$this->mapper->expects($this->never())
@@ -225,11 +225,11 @@ class BackupCodeStorageTest extends TestCase {
$this->mapper->expects($this->once())
->method('getBackupCodes')
->with($user)
- ->will($this->returnValue($codes));
+ ->willReturn($codes);
$this->hasher->expects($this->once())
->method('verify')
->with('CHALLENGE', 'HASHEDVALUE')
- ->will($this->returnValue(false));
+ ->willReturn(false);
$this->mapper->expects($this->never())
->method('update');