diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-04 20:50:58 +0300 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-10-08 20:48:12 +0300 |
commit | b6044d8bae9f6e24b28cf388c86332c362b9ab46 (patch) | |
tree | ed970d0db1e47bfc0225175fd83412f64e3604cb /tests | |
parent | 8ee9e185933153515889b87459cfad4277b29abb (diff) |
Switch to real initial state API
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Unit/Provider/TotpProviderTest.php | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/Unit/Provider/TotpProviderTest.php b/tests/Unit/Provider/TotpProviderTest.php index 813308a..411ca59 100644 --- a/tests/Unit/Provider/TotpProviderTest.php +++ b/tests/Unit/Provider/TotpProviderTest.php @@ -32,6 +32,7 @@ use OCA\TwoFactorTOTP\Provider\TotpProvider; use OCA\TwoFactorTOTP\Service\ITotp; use OCA\TwoFactorTOTP\Settings\Personal; use OCP\AppFramework\IAppContainer; +use OCP\IInitialStateService; use OCP\IL10N; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; @@ -47,6 +48,9 @@ class TotpProviderTest extends TestCase { /** @var IAppContainer|MockObject */ private $container; + /** @var IInitialStateService|MockObject */ + private $initialState; + /** @var TotpProvider */ private $provider; @@ -56,11 +60,13 @@ class TotpProviderTest extends TestCase { $this->totp = $this->createMock(ITotp::class); $this->l10n = $this->createMock(IL10N::class); $this->container = $this->createMock(IAppContainer::class); + $this->initialState = $this->createMock(IInitialStateService::class); $this->provider = new TotpProvider( $this->totp, $this->l10n, - $this->container + $this->container, + $this->initialState ); } @@ -108,12 +114,20 @@ class TotpProviderTest extends TestCase { } public function testGetPersonalSettings() { - $expected = new Personal(ITotp::STATE_ENABLED); + $expected = new Personal(); + $user = $this->createMock(IUser::class); $this->totp->expects($this->once()) ->method('hasSecret') ->with($user) ->willReturn(true); + $this->initialState->expects($this->once()) + ->method('provideInitialState') + ->with( + 'twofactor_totp', + 'state', + true + ); $actual = $this->provider->getPersonalSettings($user); |