aboutsummaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes/tests/Service
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2018-09-29 21:03:28 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2018-10-01 15:35:25 +0200
commitc55731426240c0debd3a9bad3cb5e32b6f7e76a8 (patch)
tree895addc0bdda121221d5b1d90ebe894a0622a497 /apps/twofactor_backupcodes/tests/Service
parent956fe1b86769c1a8a380a61ba72441f0e334e36a (diff)
downloadnextcloud-server-c55731426240c0debd3a9bad3cb5e32b6f7e76a8.tar.gz
nextcloud-server-c55731426240c0debd3a9bad3cb5e32b6f7e76a8.zip
Clear notification to generate backup code once codes are generated
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/twofactor_backupcodes/tests/Service')
-rw-r--r--apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
index 7d47b4ea721..679f111a75b 100644
--- a/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
+++ b/apps/twofactor_backupcodes/tests/Service/BackupCodeStorageTest.php
@@ -23,6 +23,8 @@
namespace OCA\TwoFactorBackupCodes\Tests\Service;
use OCA\TwoFactorBackupCodes\Service\BackupCodeStorage;
+use OCP\Notification\IManager;
+use OCP\Notification\INotification;
use Test\TestCase;
/**
@@ -36,10 +38,18 @@ class BackupCodeStorageTest extends TestCase {
/** @var string */
private $testUID = 'test123456789';
+ /** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
+ private $notificationManager;
+
protected function setUp() {
parent::setUp();
$this->storage = \OC::$server->query(BackupCodeStorage::class);
+
+ $this->notificationManager = $this->createMock(IManager::class);
+ $this->notificationManager->method('createNotification')
+ ->willReturn(\OC::$server->query(IManager::class)->createNotification());
+ $this->overwriteService(IManager::class, $this->notificationManager);
}
public function testSimpleWorkFlow() {
@@ -48,6 +58,15 @@ class BackupCodeStorageTest extends TestCase {
->method('getUID')
->will($this->returnValue($this->testUID));
+ $this->notificationManager->expects($this->once())
+ ->method('markProcessed')
+ ->with($this->callback(function (INotification $notification) {
+ return $notification->getUser() === $this->testUID &&
+ $notification->getObjectType() === 'create' &&
+ $notification->getObjectId() === 'codes' &&
+ $notification->getApp() === 'twofactor_backupcodes';
+ }));
+
// Create codes
$codes = $this->storage->createCodes($user, 5);
$this->assertCount(5, $codes);