diff options
author | Joas Schilling <coding@schilljs.com> | 2019-02-11 14:29:44 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-02-11 15:32:34 +0100 |
commit | 01f4506dadec86373ee629771677f837cc2a4036 (patch) | |
tree | 6005e2777005030b87286d1f89e2f8ddfa36c2fa /apps/twofactor_backupcodes/tests | |
parent | 924e40a06b2428f0dae82f5f6756e398fd5c1521 (diff) | |
download | nextcloud-server-01f4506dadec86373ee629771677f837cc2a4036.tar.gz nextcloud-server-01f4506dadec86373ee629771677f837cc2a4036.zip |
Add a link to the notification to create the backup codes
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/twofactor_backupcodes/tests')
-rw-r--r-- | apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php b/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php index 508fa453e16..9a641eb9f85 100644 --- a/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php +++ b/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php @@ -26,17 +26,21 @@ namespace OCA\TwoFactorBackupCodes\Tests\Unit\Notification; use OCA\TwoFactorBackupCodes\Notifications\Notifier; use OCP\IL10N; +use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Notification\INotification; +use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class NotifierTest extends TestCase { /** @var Notifier */ protected $notifier; - /** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IFactory|MockObject */ protected $factory; - /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IURLGenerator|MockObject */ + protected $url; + /** @var IL10N|MockObject */ protected $l; protected function setUp() { @@ -49,12 +53,14 @@ class NotifierTest extends TestCase { return vsprintf($string, $args); }); $this->factory = $this->createMock(IFactory::class); + $this->url = $this->createMock(IURLGenerator::class); $this->factory->expects($this->any()) ->method('get') ->willReturn($this->l); $this->notifier = new Notifier( - $this->factory + $this->factory, + $this->url ); } @@ -114,6 +120,15 @@ class NotifierTest extends TestCase { ->with('You have enabled two-factor authentication but have not yet generated backup codes. Be sure to do this in case you lose access to your second factor.') ->willReturnSelf(); + $this->url->expects($this->once()) + ->method('linkToRouteAbsolute') + ->with('settings.PersonalSettings.index', ['section' => 'security']) + ->willReturn('linkToRouteAbsolute'); + $notification->expects($this->once()) + ->method('setLink') + ->with('linkToRouteAbsolute') + ->willReturnSelf(); + $return = $this->notifier->prepare($notification, 'nl'); $this->assertEquals($notification, $return); } |