diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-01-07 11:46:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-07 11:46:12 +0100 |
commit | e65431d0495cb058bebe75d5e8b9ab87110cf97f (patch) | |
tree | d61e59c772b3b47534ccf1f6b3f10f620ee702cf /tests | |
parent | 1a235f5bafaed0d3998d6a9d7a5e0fa74de0c944 (diff) | |
parent | 19a3656fd95ea2a3ff5d00eb4332b0c8c6f71ea9 (diff) | |
download | nextcloud-server-e65431d0495cb058bebe75d5e8b9ab87110cf97f.tar.gz nextcloud-server-e65431d0495cb058bebe75d5e8b9ab87110cf97f.zip |
Merge pull request #30491 from nextcloud/fix/30374/email-verification
Fix email verification
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Accounts/AccountManagerTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/lib/Accounts/AccountManagerTest.php b/tests/lib/Accounts/AccountManagerTest.php index 8bb60a1a516..18419d73423 100644 --- a/tests/lib/Accounts/AccountManagerTest.php +++ b/tests/lib/Accounts/AccountManagerTest.php @@ -24,6 +24,7 @@ namespace Test\Accounts; use OC\Accounts\Account; use OC\Accounts\AccountManager; +use OCA\Settings\BackgroundJobs\VerifyUserData; use OCP\Accounts\IAccountManager; use OCP\BackgroundJob\IJobList; use OCP\Defaults; @@ -770,4 +771,42 @@ class AccountManagerTest extends TestCase { ], ]; } + + public function dataCheckEmailVerification(): array { + return [ + [$this->makeUser('steve', 'Steve Smith', 'steve@steve.steve'), null], + [$this->makeUser('emma', 'Emma Morales', 'emma@emma.com'), 'emma@morales.com'], + [$this->makeUser('sarah@web.org', 'Sarah Foster', 'sarah@web.org'), null], + [$this->makeUser('cole@web.org', 'Cole Harrison', 'cole@web.org'), 'cole@example.com'], + [$this->makeUser('8d29e358-cf69-4849-bbf9-28076c0b908b', 'Alice McPherson', 'alice@example.com'), 'alice@mcpherson.com'], + [$this->makeUser('11da2744-3f4d-4c17-8c13-4c057a379237', 'James Loranger', 'james@example.com'), ''], + ]; + } + + /** + * @dataProvider dataCheckEmailVerification + */ + public function testCheckEmailVerification(IUser $user, ?string $newEmail): void { + $account = $this->accountManager->getAccount($user); + $emailUpdated = false; + + if (!empty($newEmail)) { + $account->getProperty(IAccountManager::PROPERTY_EMAIL)->setValue($newEmail); + $emailUpdated = true; + } + + if ($emailUpdated) { + $this->jobList->expects($this->once()) + ->method('add') + ->with(VerifyUserData::class); + } else { + $this->jobList->expects($this->never()) + ->method('add') + ->with(VerifyUserData::class); + } + + /** @var array $oldData */ + $oldData = $this->invokePrivate($this->accountManager, 'getUser', [$user, false]); + $this->invokePrivate($this->accountManager, 'checkEmailVerification', [$account, $oldData]); + } } |