GenerateSecurePasswordEventTest.php 941 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test\Security\Events;
  8. use OCP\Security\Events\GenerateSecurePasswordEvent;
  9. use OCP\Security\PasswordContext;
  10. class GenerateSecurePasswordEventTest extends \Test\TestCase {
  11. public function testDefaultProperties(): void {
  12. $event = new GenerateSecurePasswordEvent();
  13. $this->assertNull($event->getPassword());
  14. $this->assertEquals(PasswordContext::ACCOUNT, $event->getContext());
  15. }
  16. public function testSettingPassword(): void {
  17. $event = new GenerateSecurePasswordEvent();
  18. $event->setPassword('example');
  19. $this->assertEquals('example', $event->getPassword());
  20. }
  21. public function testSettingContext(): void {
  22. $event = new GenerateSecurePasswordEvent(PasswordContext::SHARING);
  23. $this->assertEquals(PasswordContext::SHARING, $event->getContext());
  24. }
  25. }