diff --git a/tests/integration/service/RegistrationServiceTest.php b/tests/integration/service/RegistrationServiceTest.php index 9d9c5a2..1a58cc5 100644 --- a/tests/integration/service/RegistrationServiceTest.php +++ b/tests/integration/service/RegistrationServiceTest.php @@ -23,7 +23,6 @@ use OCP\IUser; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\IUserSession; -//use \Test\TestCase; use ChristophWurst\Nextcloud\Testing\DatabaseTransaction; use ChristophWurst\Nextcloud\Testing\TestCase; @@ -71,13 +70,12 @@ class RegistrationServiceTest extends TestCase { $this->mailService = $this->createMock(MailService::class); $this->l10n = $this->createMock(IL10N::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); - $this->registrationMapper = $this->createMock(RegistrationMapper::class); #$this->userManager = $this->createMock(IUserManager::class); $this->userManager = \OC::$server->getUserManager(); $this->config = $this->createMock(IConfig::class); $this->groupManager = \OC::$server->getGroupManager(); $this->defaults = $this->createMock(Defaults::class); - $this->random = $this->createMock(ISecureRandom::class); + $this->random = \OC::$server->getSecureRandom(); $this->usersession = $this->createMock(IUserSession::class); $this->request = $this->createMock(IRequest::class); $this->logger = $this->createMock(ILogger::class); @@ -85,6 +83,11 @@ class RegistrationServiceTest extends TestCase { $this->tokenProvider = $this->createMock(IProvider::class); $this->crypto = $this->createMock(ICrypto::class); + $this->registrationMapper = new RegistrationMapper( + \OC::$server->getDatabaseConnection(), + $this->random + ); + $this->service = new RegistrationService( 'registration', $this->mailService, @@ -105,6 +108,30 @@ class RegistrationServiceTest extends TestCase { ); } + public function testValidateNewEmail() { + $email = 'aaaa@example.com'; + + $this->config->expects($this->at(0)) + ->method('getAppValue') + ->with("registration", 'allowed_domains', '') + ->willReturn(''); + + $ret = $this->service->validateEmail($email); + + //$this->assertInstanceOf(Registration::class, $ret); + $this->assertTrue($ret); + } + + public function testValidatePendingReg() { + $email = 'aaaa@example.com'; + + $this->service->createRegistration($email, 'alice'); + $ret = $this->service->validateEmail($email); + + $this->assertInstanceOf(Registration::class, $ret); + $this->assertEquals($email, $ret->getEmail()); + } + public function testCreateAccountWebForm() { $reg = new Registration(); $reg->setEmail("asd@example.com");